Class: DocRSpec::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_rspec/parser.rb

Defined Under Namespace

Classes: InternalError, SyntaxError

Constant Summary collapse

CONTEXT_DEFINITION =
%r{\A \s* \# \s ={1,7} \s (.*)}x
EQUALS_OP =
%r{\s+ => \s+}x
EXAMPLE_LINE =
%r{\A \s* \# \s{4,} (.*)}x
START_EXAMPLE =
%r{\A \s* \# \s{4,} \# \s example: \s (.*)}x

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



18
19
20
# File 'lib/doc_rspec/parser.rb', line 18

def ast
  @ast
end

#linesObject (readonly)

Returns the value of attribute lines.



18
19
20
# File 'lib/doc_rspec/parser.rb', line 18

def lines
  @lines
end

#stateObject (readonly)

Returns the value of attribute state.



18
19
20
# File 'lib/doc_rspec/parser.rb', line 18

def state
  @state
end

Instance Method Details

#parseObject



20
21
22
23
24
25
# File 'lib/doc_rspec/parser.rb', line 20

def parse
  lines.each_with_index do |line, lnb|
    parse_line(line, lnb.succ)
  end
  ast.reject(&:empty?)
end