Class: Attentive::StringToken

Inherits:
Token
  • Object
show all
Defined in:
lib/attentive/token.rb

Instance Attribute Summary collapse

Attributes inherited from Token

#begin

Instance Method Summary collapse

Methods inherited from Token

#ambiguous?, #end, #entity?, #eof?, #inspect, #matches?, #skippable?, #whitespace?

Constructor Details

#initialize(string, pos = nil) ⇒ StringToken

Returns a new instance of StringToken.



57
58
59
60
# File 'lib/attentive/token.rb', line 57

def initialize(string, pos=nil)
  @string = string
  super pos
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



55
56
57
# File 'lib/attentive/token.rb', line 55

def string
  @string
end

Instance Method Details

#==(other) ⇒ Object



74
75
76
# File 'lib/attentive/token.rb', line 74

def ==(other)
  self.class == other.class && self.string == other.string
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/attentive/token.rb', line 78

def eql?(other)
  self == other
end

#hashObject



82
83
84
# File 'lib/attentive/token.rb', line 82

def hash
  [ self.class, string ].hash
end

#lengthObject



70
71
72
# File 'lib/attentive/token.rb', line 70

def length
  string.length
end

#to_sObject



66
67
68
# File 'lib/attentive/token.rb', line 66

def to_s
  string
end

#to_strObject



62
63
64
# File 'lib/attentive/token.rb', line 62

def to_str
  to_s
end