Class: GG::State

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.



5
6
7
8
# File 'lib/gg/state.rb', line 5

def initialize
  @hash = {}
  @depth = 2
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

Instance Method Details

#add(value) ⇒ Object



14
15
16
# File 'lib/gg/state.rb', line 14

def add(value)
  hash[value.object_id] = true
end

#depth(value = nil) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/gg/state.rb', line 18

def depth(value=nil)
  if value.nil?
    @depth
  else
    @depth = depth
  end
end

#exists?(value) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/gg/state.rb', line 10

def exists?(value)
  hash.key?(value.object_id)
end