Sha256: cb35a69e1e259b2609bae31b501294af35090b81bfdd83c4952a7c343b25967b

Contents?: true

Size: 500 Bytes

Versions: 19

Compression:

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

19 entries across 19 versions & 1 rubygems

Version Path
dentaku-1.0.0 lib/dentaku/token.rb
dentaku-0.2.14 lib/dentaku/token.rb
dentaku-0.2.13 lib/dentaku/token.rb
dentaku-0.2.12 lib/dentaku/token.rb
dentaku-0.2.11 lib/dentaku/token.rb
dentaku-0.2.10 lib/dentaku/token.rb
dentaku-0.2.9 lib/dentaku/token.rb
dentaku-0.2.8 lib/dentaku/token.rb
dentaku-0.2.7 lib/dentaku/token.rb
dentaku-0.2.6 lib/dentaku/token.rb
dentaku-0.2.5 lib/dentaku/token.rb
dentaku-0.2.4 lib/dentaku/token.rb
dentaku-0.2.3 lib/dentaku/token.rb
dentaku-0.2.2 lib/dentaku/token.rb
dentaku-0.2.1 lib/dentaku/token.rb
dentaku-0.1.3 lib/dentaku/token.rb
dentaku-0.1.2 lib/dentaku/token.rb
dentaku-0.1.1 lib/dentaku/token.rb
dentaku-0.1.0 lib/dentaku/token.rb