class DParse::Parsers::Map

Public Class Methods

new(parser, &block) click to toggle source
# File lib/d-parse/parsers/modifiers/map.rb, line 4
def initialize(parser, &block)
  @parser = parser
  @block = block
end

Public Instance Methods

inspect() click to toggle source
# File lib/d-parse/parsers/modifiers/map.rb, line 19
def inspect
  "map(#{@parser}, <proc>)"
end
read(input, pos) click to toggle source
# File lib/d-parse/parsers/modifiers/map.rb, line 9
def read(input, pos)
  res = @parser.read(input, pos)
  case res
  when Success
    Success.new(input, res.pos, data: @block.call(res.data, res, pos), best_failure: res.best_failure)
  when Failure
    res
  end
end