Class: CiscoSpark::Collection

Inherits:
Object
  • Object
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 = [])
  # we can broke no delay
  @items = items
end

Instance Attribute Details

#itemsObject

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

#eachObject



26
27
28
# File 'lib/collection.rb', line 26

def each
  @items.each { |r| yield r }
end

#lengthObject



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_sObject



22
23
24
# File 'lib/collection.rb', line 22

def to_s
  @items.to_s
end