Class: EverExp::Html::Heading::Title

Inherits:
Object
  • Object
show all
Defined in:
lib/ever_exp/heading.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lvl, ti) ⇒ Title

Returns a new instance of Title.



31
32
33
34
35
# File 'lib/ever_exp/heading.rb', line 31

def initialize lvl, ti
  @level = lvl
  @title = ti
  @subtitles = []
end

Instance Attribute Details

#levelObject (readonly)

Returns the value of attribute level.



28
29
30
# File 'lib/ever_exp/heading.rb', line 28

def level
  @level
end

#parent_titleObject

Returns the value of attribute parent_title.



29
30
31
# File 'lib/ever_exp/heading.rb', line 29

def parent_title
  @parent_title
end

#subtitlesObject (readonly)

Returns the value of attribute subtitles.



28
29
30
# File 'lib/ever_exp/heading.rb', line 28

def subtitles
  @subtitles
end

#titleObject (readonly)

Returns the value of attribute title.



28
29
30
# File 'lib/ever_exp/heading.rb', line 28

def title
  @title
end

Instance Method Details

#add_sib(node) ⇒ Object



46
47
48
# File 'lib/ever_exp/heading.rb', line 46

def add_sib node
  parent_title.add_sub node
end

#add_sub(node) ⇒ Object



41
42
43
44
# File 'lib/ever_exp/heading.rb', line 41

def add_sub node
  node.parent_title = self
  subtitles << node
end

#last_subtitleObject



37
38
39
# File 'lib/ever_exp/heading.rb', line 37

def last_subtitle
  subtitles.last
end

#to_hObject



50
51
52
53
# File 'lib/ever_exp/heading.rb', line 50

def to_h
  return title if subtitles.empty?
  {title => subtitles.map(&:to_h)}
end