Class: Speculations::Parser::Context::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/speculations/parser/context/example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lnbObject (readonly)

Returns the value of attribute lnb.



3
4
5
# File 'lib/speculations/parser/context/example.rb', line 3

def lnb
  @lnb
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/speculations/parser/context/example.rb', line 3

def parent
  @parent
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/speculations/parser/context/example.rb', line 3

def title
  @title
end

Instance Method Details

#add_line(line) ⇒ Object



5
6
7
8
# File 'lib/speculations/parser/context/example.rb', line 5

def add_line line
  lines << _format_line(line)
  self
end

#info(label) ⇒ Object



20
21
22
23
# File 'lib/speculations/parser/context/example.rb', line 20

def info(label) 
  return unless ENV["DEBUG"]
  $stderr.puts({class: :Example, lnb:, label:, title:}.inspect)
end

#linesObject



10
11
12
# File 'lib/speculations/parser/context/example.rb', line 10

def lines
  @__lines__ ||= [] 
end

#to_codeObject



14
15
16
17
18
# File 'lib/speculations/parser/context/example.rb', line 14

def to_code
  parent.map_lines(_example_head) +
    parent.map_lines(lines, indent: 1) +
    parent.map_lines("end")
end