Class: EverExp::Html::Heading

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

Defined Under Namespace

Classes: Title

Instance Method Summary collapse

Constructor Details

#initializeHeading

Returns a new instance of Heading.



4
5
6
# File 'lib/ever_exp/heading.rb', line 4

def initialize
  @h = Title.new '999', 'heading'
end

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_hObject



22
23
24
# File 'lib/ever_exp/heading.rb', line 22

def to_h
  h.subtitles.map(&:to_h)
end