Class: Longjing::State
- Inherits:
-
Object
- Object
- Longjing::State
- Defined in:
- lib/longjing/state.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #<=>(s) ⇒ Object
- #==(state) ⇒ Object (also: #eql?)
-
#initialize(raw, path = []) ⇒ State
constructor
A new instance of State.
- #to_s ⇒ Object
Constructor Details
#initialize(raw, path = []) ⇒ State
Returns a new instance of State.
6 7 8 9 10 11 |
# File 'lib/longjing/state.rb', line 6 def initialize(raw, path=[]) @raw = raw @path = path @hash = @raw.hash @cost = 0 end |
Instance Attribute Details
#cost ⇒ Object
Returns the value of attribute cost.
4 5 6 |
# File 'lib/longjing/state.rb', line 4 def cost @cost end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
3 4 5 |
# File 'lib/longjing/state.rb', line 3 def hash @hash end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/longjing/state.rb', line 3 def path @path end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
3 4 5 |
# File 'lib/longjing/state.rb', line 3 def raw @raw end |
Instance Method Details
#<=>(s) ⇒ Object
23 24 25 |
# File 'lib/longjing/state.rb', line 23 def <=>(s) @cost <=> s.cost end |
#==(state) ⇒ Object Also known as: eql?
13 14 15 16 |
# File 'lib/longjing/state.rb', line 13 def ==(state) return true if state.object_id == self.object_id @raw == state.raw end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/longjing/state.rb', line 19 def to_s "{#{@raw.to_a.join(" ")}}" end |