Class: TwitterCldr::Tokenizers::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/tokenizers/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Token

Returns a new instance of Token.



11
12
13
14
15
# File 'lib/twitter_cldr/tokenizers/token.rb', line 11

def initialize(options = {})
  options.each_pair do |key, val|
    self.send("#{key.to_s}=", val)
  end
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/twitter_cldr/tokenizers/token.rb', line 9

def type
  @type
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/twitter_cldr/tokenizers/token.rb', line 9

def value
  @value
end

Instance Method Details

#inspectObject

overriding ‘to_s` also overrides `inspect`, so we have to redefine it manually



26
27
28
# File 'lib/twitter_cldr/tokenizers/token.rb', line 26

def inspect
  "<#{self.class}: #{instance_variables.map {|v| "#{v}=#{instance_variable_get(v).inspect}" }.join(", ")}>"
end

#to_hashObject



17
18
19
# File 'lib/twitter_cldr/tokenizers/token.rb', line 17

def to_hash
  { value: @value, type: @type }
end

#to_sObject



21
22
23
# File 'lib/twitter_cldr/tokenizers/token.rb', line 21

def to_s
  @value
end