Class: Okura::Word
- Inherits:
-
Object
- Object
- Okura::Word
- Defined in:
- lib/okura.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
readonly
Integer.
-
#left ⇒ Object
readonly
Feature.
-
#right ⇒ Object
readonly
Feature.
-
#surface ⇒ Object
readonly
String.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #hash ⇒ Object
-
#initialize(surface, left, right, cost) ⇒ Word
constructor
A new instance of Word.
- #to_s ⇒ Object
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
#cost ⇒ Object (readonly)
Integer
227 228 229 |
# File 'lib/okura.rb', line 227 def cost @cost end |
#left ⇒ Object (readonly)
Feature
223 224 225 |
# File 'lib/okura.rb', line 223 def left @left end |
#right ⇒ Object (readonly)
Feature
225 226 227 |
# File 'lib/okura.rb', line 225 def right @right end |
#surface ⇒ Object (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 |
#hash ⇒ Object
232 233 234 |
# File 'lib/okura.rb', line 232 def hash [surface,left,right,cost].hash end |
#to_s ⇒ Object
235 236 237 |
# File 'lib/okura.rb', line 235 def to_s "Word(#{surface},#{left.id},#{right.id},#{cost})" end |