Class: Rsec::RepeatN

Inherits:
Struct
  • Object
show all
Includes:
Parser
Defined in:
lib/rsec/parsers/repeat.rb

Overview

matches exactly n.abs times repeat<br/>

Instance Attribute Summary collapse

Attributes included from Parser

#name

Instance Method Summary collapse

Methods included from Parser

#&, #*, #<<, #>>, #^, #cached, #eof, #fail, #inspect, #join, #map, #maybe, #parse, #parse!, #star, #|

Instance Attribute Details

#baseObject

Returns the value of attribute base

Returns:

  • (Object)

    the current value of base



54
55
56
# File 'lib/rsec/parsers/repeat.rb', line 54

def base
  @base
end

#nObject

Returns the value of attribute n

Returns:

  • (Object)

    the current value of n



54
55
56
# File 'lib/rsec/parsers/repeat.rb', line 54

def n
  @n
end

Instance Method Details

#_parse(ctx) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/rsec/parsers/repeat.rb', line 56

def _parse ctx
  n.times.inject([]) do |rp_node|
    res = base._parse ctx
    return INVALID if INVALID[res]
    rp_node.push res
  end
end