Class: KO::Children
Instance Method Summary collapse
-
#[](id) ⇒ Object
TODO: use index.
- #add(obj) ⇒ Object
- #count ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Children
constructor
A new instance of Children.
- #inspect ⇒ Object
- #pretty_inspect ⇒ Object
- #remove(obj) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ Children
Returns a new instance of Children.
7 8 9 |
# File 'lib/ko/children.rb', line 7 def initialize @store = {} end |
Instance Method Details
#[](id) ⇒ Object
TODO: use index
12 |
# File 'lib/ko/children.rb', line 12 def [](id) = @store.find { _1.id == id } |
#add(obj) ⇒ Object
14 |
# File 'lib/ko/children.rb', line 14 def add(obj) = @store[obj] = obj |
#count ⇒ Object
28 |
# File 'lib/ko/children.rb', line 28 def count(...) = @store.count(...) |
#each ⇒ Object
27 |
# File 'lib/ko/children.rb', line 27 def each(...) = @store.each_key(...) |
#inspect ⇒ Object
24 |
# File 'lib/ko/children.rb', line 24 def inspect = to_a.inspect |
#pretty_inspect ⇒ Object
25 |
# File 'lib/ko/children.rb', line 25 def pretty_inspect = to_a.pretty_inspect |
#remove(obj) ⇒ Object
16 17 18 19 20 |
# File 'lib/ko/children.rb', line 16 def remove(obj) raise UnknownChildError unless @store.include?(obj) @store.delete(obj) end |
#to_a ⇒ Object
22 |
# File 'lib/ko/children.rb', line 22 def to_a = @store.keys |