Class: Lab42::Literate::Extractor::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/lab42/literate/extractor/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



6
7
8
# File 'lib/lab42/literate/extractor/block.rb', line 6

def lines
  @lines
end

#start_lnbObject (readonly)

Returns the value of attribute start_lnb.



6
7
8
# File 'lib/lab42/literate/extractor/block.rb', line 6

def start_lnb
  @start_lnb
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/lab42/literate/extractor/block.rb', line 6

def title
  @title
end

Instance Method Details

#add_line(line) ⇒ Object



8
9
10
# File 'lib/lab42/literate/extractor/block.rb', line 8

def add_line line
  lines << line
end

#get_title(alternative) ⇒ Object



13
14
15
# File 'lib/lab42/literate/extractor/block.rb', line 13

def get_title alternative
  title.empty? ?  alternative : title
end

#given?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/lab42/literate/extractor/block.rb', line 18

def given?
  parsed.children.first.children == [nil, :Given]
rescue
  false
end

#rangeObject



24
25
26
# File 'lib/lab42/literate/extractor/block.rb', line 24

def range
  start_lnb..(start_lnb.pred + lines.size)
end