Sha256: 2d3612037533a2afe22070ff7fa722689eb4f5f2ee165e884020b7cce524abe7

Contents?: true

Size: 595 Bytes

Versions: 12

Compression:

Stored size: 595 Bytes

Contents

module Dentaku
  class Token
    attr_reader :category, :raw_value, :value

    def initialize(category, value, raw_value=nil)
      @category  = category
      @value     = value
      @raw_value = raw_value
    end

    def to_s
      raw_value || value
    end

    def length
      raw_value.to_s.length
    end

    def grouping?
      is?(:grouping)
    end

    def is?(c)
      category == c
    end

    def ==(other)
      (category.nil? || other.category.nil? || category == other.category) &&
      (value.nil?    || other.value.nil?    || value    == other.value)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dentaku-2.0.11 lib/dentaku/token.rb
dentaku-2.0.10 lib/dentaku/token.rb
dentaku-2.0.9 lib/dentaku/token.rb
dentaku-2.0.8 lib/dentaku/token.rb
dentaku-2.0.7 lib/dentaku/token.rb
dentaku-2.0.6 lib/dentaku/token.rb
dentaku-2.0.5 lib/dentaku/token.rb
dentaku-2.0.4 lib/dentaku/token.rb
dentaku-2.0.3 lib/dentaku/token.rb
dentaku-2.0.2 lib/dentaku/token.rb
dentaku-2.0.1 lib/dentaku/token.rb
dentaku-2.0.0 lib/dentaku/token.rb