Class: DParse::Parsers::Lazy

Inherits:
DParse::Parser show all
Defined in:
lib/d-parse/parsers/modifiers/lazy.rb

Instance Method Summary collapse

Methods inherited from DParse::Parser

#apply, #bind, #capture, #compact, #expectation_message, #first, #flatten, #ignore, #map, #match?, #second, #select_even, #select_odd, #to_s

Constructor Details

#initialize(&block) ⇒ Lazy

Returns a new instance of Lazy.

Raises:

  • (ArgumentError)


4
5
6
7
# File 'lib/d-parse/parsers/modifiers/lazy.rb', line 4

def initialize(&block)
  raise ArgumentError, 'Expected block' unless block_given?
  @block = block
end

Instance Method Details

#inspectObject



13
14
15
# File 'lib/d-parse/parsers/modifiers/lazy.rb', line 13

def inspect
  'lazy(?)'
end

#read(input, pos) ⇒ Object



9
10
11
# File 'lib/d-parse/parsers/modifiers/lazy.rb', line 9

def read(input, pos)
  @block.call.read(input, pos)
end