Sha256: b9b54785a7ff7398cd07c3cae9c00fbb2cb100c4b7a0cb9c993af8b499eeb961

Contents?: true

Size: 547 Bytes

Versions: 8

Compression:

Stored size: 547 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 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

8 entries across 8 versions & 1 rubygems

Version Path
dentaku-1.2.6 lib/dentaku/token.rb
dentaku-1.2.5 lib/dentaku/token.rb
dentaku-1.2.4 lib/dentaku/token.rb
dentaku-1.2.3 lib/dentaku/token.rb
dentaku-1.2.2 lib/dentaku/token.rb
dentaku-1.2.1 lib/dentaku/token.rb
dentaku-1.2.0 lib/dentaku/token.rb
dentaku-1.1.0 lib/dentaku/token.rb