Class: Leg::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/leg/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = "tutorial") ⇒ Page

Returns a new instance of Page.



5
6
7
8
9
# File 'lib/leg/page.rb', line 5

def initialize(filename = "tutorial")
  @filename = filename
  @steps = []
  @footer_text = nil
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



3
4
5
# File 'lib/leg/page.rb', line 3

def filename
  @filename
end

Returns the value of attribute footer_text.



3
4
5
# File 'lib/leg/page.rb', line 3

def footer_text
  @footer_text
end

#stepsObject

Returns the value of attribute steps.



3
4
5
# File 'lib/leg/page.rb', line 3

def steps
  @steps
end

Instance Method Details

#<<(step) ⇒ Object



11
12
13
14
# File 'lib/leg/page.rb', line 11

def <<(step)
  @steps << step
  self
end

#empty?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/leg/page.rb', line 16

def empty?
  @steps.empty?
end

#titleObject



20
21
22
23
24
25
# File 'lib/leg/page.rb', line 20

def title
  first_line = @steps.first ? @steps.first.text.lines.first : (@footer_text ? @footer_text.lines.first : nil)
  if first_line && first_line.start_with?("# ")
    first_line[2..-1].strip
  end
end