class Dentaku::Token

Attributes

category[R]
raw_value[R]
value[R]

Public Class Methods

new(category, value, raw_value = nil) click to toggle source
# File lib/dentaku/token.rb, line 5
def initialize(category, value, raw_value = nil)
  @category  = category
  @value     = value
  @raw_value = raw_value
end

Public Instance Methods

==(other) click to toggle source
# File lib/dentaku/token.rb, line 43
def ==(other)
  (category.nil? || other.category.nil? || category == other.category) &&
  (value.nil?    || other.value.nil?    || value    == other.value)
end
close?() click to toggle source
# File lib/dentaku/token.rb, line 35
def close?
  grouping? && value == :close
end
empty?() click to toggle source
# File lib/dentaku/token.rb, line 19
def empty?
  length.zero?
end
grouping?() click to toggle source
# File lib/dentaku/token.rb, line 27
def grouping?
  is?(:grouping)
end
is?(c) click to toggle source
# File lib/dentaku/token.rb, line 39
def is?(c)
  category == c
end
length() click to toggle source
# File lib/dentaku/token.rb, line 15
def length
  raw_value.to_s.length
end
open?() click to toggle source
# File lib/dentaku/token.rb, line 31
def open?
  grouping? && value == :open
end
operator?() click to toggle source
# File lib/dentaku/token.rb, line 23
def operator?
  is?(:operator)
end
to_s() click to toggle source
# File lib/dentaku/token.rb, line 11
def to_s
  raw_value || value
end