ddfreyne/d-parse

View on GitHub
lib/d-parse/parsers/modifiers/lazy.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module DParse
  module Parsers
    class Lazy < DParse::Parser
      def initialize(&block)
        raise ArgumentError, 'Expected block' unless block_given?

        @block = block
      end

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

      def inspect
        'lazy(?)'
      end
    end
  end
end