Class: DocRSpec::Ast

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_rspec/ast.rb,
lib/doc_rspec/ast/example.rb

Defined Under Namespace

Classes: Example

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#examplesObject (readonly)

Returns the value of attribute examples.



6
7
8
# File 'lib/doc_rspec/ast.rb', line 6

def examples
  @examples
end

#lnbObject (readonly)

Returns the value of attribute lnb.



6
7
8
# File 'lib/doc_rspec/ast.rb', line 6

def lnb
  @lnb
end

Instance Method Details

#add_example(lnb, match) ⇒ Object



8
9
10
# File 'lib/doc_rspec/ast.rb', line 8

def add_example(lnb, match)
  examples << Example.new(lnb, match)
end

#add_example_line(op, lhs, rhs = nil) ⇒ Object



12
13
14
# File 'lib/doc_rspec/ast.rb', line 12

def add_example_line(op, lhs, rhs=nil)
  examples.last.add(op, lhs, rhs)
end

#close_example(&error_handler) ⇒ Object



16
17
18
19
20
# File 'lib/doc_rspec/ast.rb', line 16

def close_example(&error_handler)
  return unless examples.last.lines.empty?

  error_handler.()
end

#context_name(path) ⇒ Object



22
23
24
# File 'lib/doc_rspec/ast.rb', line 22

def context_name(path)
  "docspec #{path}:#{lnb}"
end