class TwitterKorean::KoreanToken::Metadata

Attributes

length[RW]
offset[RW]
pos[RW]
unkown[RW]

Public Class Methods

new(attrs = {}) click to toggle source
# File lib/twitter_korean/korean_token.rb, line 25
def initialize(attrs = {})
  attrs.each { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
  symbolize_pos!
end

Public Instance Methods

==(other) click to toggle source
# File lib/twitter_korean/korean_token.rb, line 34
def ==(other)
  [:pos, :offset, :length, :unkown].inject(true) { |res, attr| res && (send(attr) == other.send(attr)) }
end
inspect() click to toggle source
# File lib/twitter_korean/korean_token.rb, line 30
def inspect
  "#{pos}, #{offset}, #{length}"
end

Private Instance Methods

symbolize_pos!() click to toggle source
# File lib/twitter_korean/korean_token.rb, line 40
def symbolize_pos!
  return if pos.nil?
  @pos = to_underscore(pos).to_sym
end
to_underscore(txt) click to toggle source
# File lib/twitter_korean/korean_token.rb, line 45
def to_underscore(txt)
  txt.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end