Class: GG::State
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
- #add(value) ⇒ Object
- #depth(value = nil) ⇒ Object
- #exists?(value) ⇒ Boolean
-
#initialize ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize ⇒ State
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
#hash ⇒ Object (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
10 11 12 |
# File 'lib/gg/state.rb', line 10 def exists?(value) hash.key?(value.object_id) end |