Sha256: 6ee16aff448586fd38f121f24a7d4eeb757854e4419544b39df6d52870ddca2b

Contents?: true

Size: 454 Bytes

Versions: 2

Compression:

Stored size: 454 Bytes

Contents

# frozen_string_literal: true

module Farseer
  class Char
    include MapFactory

    def initialize(char)
      @char = char
      freeze
    end

    L_PARENS = new('(')
    R_PARENS = new(')')
    PLUS     = new('+')
    MINUS    = new('-')
    STAR     = new('*')
    SLASH    = new('/')

    def parse(input)
      case input[0]
      when @char then Maybe.return(Result.new(input[0], input[1..]))
      else Maybe.none
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
farseer-0.9.0 lib/farseer/char.rb
farseer-0.8.0 lib/farseer/char.rb