Class: CiscoSpark::Collection
- Inherits:
-
Object
- Object
- CiscoSpark::Collection
show all
- Includes:
- Enumerable
- Defined in:
- lib/collection.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(items = []) ⇒ Collection
Returns a new instance of Collection.
5
6
7
8
|
# File 'lib/collection.rb', line 5
def initialize(items = [])
@items = items
end
|
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
4
5
6
|
# File 'lib/collection.rb', line 4
def items
@items
end
|
Instance Method Details
#[](key) ⇒ Object
18
19
20
|
# File 'lib/collection.rb', line 18
def [](key)
@items[key]
end
|
#each ⇒ Object
26
27
28
|
# File 'lib/collection.rb', line 26
def each
@items.each { |r| yield r }
end
|
#length ⇒ Object
14
15
16
|
# File 'lib/collection.rb', line 14
def length
@items.length
end
|
#push(item) ⇒ Object
10
11
12
|
# File 'lib/collection.rb', line 10
def push(item)
@items.push(item)
end
|
#to_s ⇒ Object
22
23
24
|
# File 'lib/collection.rb', line 22
def to_s
@items.to_s
end
|