Class: KPeg::Sequence
Instance Attribute Summary collapse
-
#ops ⇒ Object
readonly
Returns the value of attribute ops.
Attributes inherited from Operator
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(*ops) ⇒ Sequence
constructor
A new instance of Sequence.
- #inspect ⇒ Object
- #match(x) ⇒ Object
Methods inherited from Operator
#detect_tags, #inspect_type, #prune_values, #set_action, #|
Constructor Details
#initialize(*ops) ⇒ Sequence
Returns a new instance of Sequence.
303 304 305 306 307 |
# File 'lib/kpeg/grammar.rb', line 303 def initialize(*ops) super() @ops = ops ops end |
Instance Attribute Details
#ops ⇒ Object (readonly)
Returns the value of attribute ops.
309 310 311 |
# File 'lib/kpeg/grammar.rb', line 309 def ops @ops end |
Instance Method Details
#==(obj) ⇒ Object
324 325 326 327 328 329 330 331 |
# File 'lib/kpeg/grammar.rb', line 324 def ==(obj) case obj when Sequence @ops == obj.ops else super end end |
#inspect ⇒ Object
333 334 335 |
# File 'lib/kpeg/grammar.rb', line 333 def inspect inspect_type "seq", @ops.map { |i| i.inspect }.join(' ') end |
#match(x) ⇒ Object
311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/kpeg/grammar.rb', line 311 def match(x) start = x.pos matches = @ops.map do |n| m = n.match(x) unless m x.pos = start return nil end m end MatchComposition.new(self, matches) end |