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