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

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

Constant Summary collapse

NAMED_EXAMPLE =
%r{\A[`~]{3,}ruby\s+:example\s+(.*)}

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

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
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

Instance Method Details

#add_line(line) ⇒ Object



7
8
9
10
# File 'lib/speculations/parser/context/example.rb', line 7

def add_line line
  lines << line
  self
end

#linesObject



12
13
14
# File 'lib/speculations/parser/context/example.rb', line 12

def lines
   @__lines__ ||= [] 
end

#to_codeObject



16
17
18
19
20
21
22
# File 'lib/speculations/parser/context/example.rb', line 16

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