Sha256: dbd3e3b6d95b811807391adc55ead15355ea4231370975fae0b52945b0cfcfcf

Contents?: true

Size: 685 Bytes

Versions: 14

Compression:

Stored size: 685 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Tokenizers
    class Token
      attr_accessor :value, :type

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

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

      def to_s
        @value
      end

      # overriding `to_s` also overrides `inspect`, so we have to redefine it manually
      def inspect
        "<#{self.class}: #{instance_variables.map {|v| "#{v}=#{instance_variable_get(v).inspect}" }.join(", ")}>"
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/tokenizers/token.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/twitter_cldr-3.2.1/lib/twitter_cldr/tokenizers/token.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/twitter_cldr-3.1.2/lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.2.1 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.2.0 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.1.2 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.1.1 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.1.0 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.0.10 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.0.9 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.0.8 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.0.7 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.0.6 lib/twitter_cldr/tokenizers/token.rb
twitter_cldr-3.0.5 lib/twitter_cldr/tokenizers/token.rb