Class: EverExp::Html::Heading
- Inherits:
-
Object
- Object
- EverExp::Html::Heading
- Defined in:
- lib/ever_exp/heading.rb
Defined Under Namespace
Classes: Title
Instance Method Summary collapse
- #add(level, title) ⇒ Object
-
#initialize ⇒ Heading
constructor
A new instance of Heading.
- #to_h ⇒ Object
Constructor Details
Instance Method Details
#add(level, title) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ever_exp/heading.rb', line 8 def add level, title subtitle = Title.new level, title last_st = h.last_subtitle title = h while true do if last_st.nil? or last_st.level == subtitle.level title.add_sub subtitle return end title = last_st last_st = last_st.last_subtitle end end |
#to_h ⇒ Object
22 23 24 |
# File 'lib/ever_exp/heading.rb', line 22 def to_h h.subtitles.map(&:to_h) end |