Class: Okura::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/okura.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(surface, left, right, cost) ⇒ Word

Returns a new instance of Word.



216
217
218
219
# File 'lib/okura.rb', line 216

def initialize surface,left,right,cost
  raise "bad feature: #{left.inspect}" unless left.respond_to? :text
  @surface,@left,@right,@cost=surface,left,right,cost
end

Instance Attribute Details

#costObject (readonly)

Integer



227
228
229
# File 'lib/okura.rb', line 227

def cost
  @cost
end

#leftObject (readonly)

Feature



223
224
225
# File 'lib/okura.rb', line 223

def left
  @left
end

#rightObject (readonly)

Feature



225
226
227
# File 'lib/okura.rb', line 225

def right
  @right
end

#surfaceObject (readonly)

String



221
222
223
# File 'lib/okura.rb', line 221

def surface
  @surface
end

Instance Method Details

#==(other) ⇒ Object



228
229
230
231
# File 'lib/okura.rb', line 228

def == other
  return [surface,left,right,cost] ==
    [other.surface,other.left,other.right,other.cost]
end

#hashObject



232
233
234
# File 'lib/okura.rb', line 232

def hash
  [surface,left,right,cost].hash
end

#to_sObject



235
236
237
# File 'lib/okura.rb', line 235

def to_s
  "Word(#{surface},#{left.id},#{right.id},#{cost})"
end