Class: EverExp::Html::Heading::Title
- Inherits:
-
Object
- Object
- EverExp::Html::Heading::Title
- Defined in:
- lib/ever_exp/heading.rb
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#parent_title ⇒ Object
Returns the value of attribute parent_title.
-
#subtitles ⇒ Object
readonly
Returns the value of attribute subtitles.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #add_sib(node) ⇒ Object
- #add_sub(node) ⇒ Object
-
#initialize(lvl, ti) ⇒ Title
constructor
A new instance of Title.
- #last_subtitle ⇒ Object
- #to_h ⇒ Object
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
#level ⇒ Object (readonly)
Returns the value of attribute level.
28 29 30 |
# File 'lib/ever_exp/heading.rb', line 28 def level @level end |
#parent_title ⇒ Object
Returns the value of attribute parent_title.
29 30 31 |
# File 'lib/ever_exp/heading.rb', line 29 def parent_title @parent_title end |
#subtitles ⇒ Object (readonly)
Returns the value of attribute subtitles.
28 29 30 |
# File 'lib/ever_exp/heading.rb', line 28 def subtitles @subtitles end |
#title ⇒ Object (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_subtitle ⇒ Object
37 38 39 |
# File 'lib/ever_exp/heading.rb', line 37 def last_subtitle subtitles.last end |
#to_h ⇒ Object
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 |