Class: Longjing::State

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#costObject

Returns the value of attribute cost.



4
5
6
# File 'lib/longjing/state.rb', line 4

def cost
  @cost
end

#hashObject (readonly)

Returns the value of attribute hash.



3
4
5
# File 'lib/longjing/state.rb', line 3

def hash
  @hash
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/longjing/state.rb', line 3

def path
  @path
end

#rawObject (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_sObject



19
20
21
# File 'lib/longjing/state.rb', line 19

def to_s
  "{#{@raw.to_a.join(" ")}}"
end