Class: Soundcloud2000::Models::Collection
- Inherits:
-
Object
- Object
- Soundcloud2000::Models::Collection
- Includes:
- Enumerable
- Defined in:
- lib/soundcloud2000/models/collection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #append(rows) ⇒ Object
- #clear ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(client) ⇒ Collection
constructor
A new instance of Collection.
- #replace(rows) ⇒ Object
Constructor Details
#initialize(client) ⇒ Collection
Returns a new instance of Collection.
9 10 11 12 13 |
# File 'lib/soundcloud2000/models/collection.rb', line 9 def initialize(client) @client = client @events = Events.new clear end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
7 8 9 |
# File 'lib/soundcloud2000/models/collection.rb', line 7 def events @events end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
7 8 9 |
# File 'lib/soundcloud2000/models/collection.rb', line 7 def page @page end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
7 8 9 |
# File 'lib/soundcloud2000/models/collection.rb', line 7 def rows @rows end |
Instance Method Details
#[](*args) ⇒ Object
15 16 17 |
# File 'lib/soundcloud2000/models/collection.rb', line 15 def [](*args) @rows[*args] end |
#append(rows) ⇒ Object
35 36 37 38 |
# File 'lib/soundcloud2000/models/collection.rb', line 35 def append(rows) @rows += rows events.trigger(:append) end |
#clear ⇒ Object
19 20 21 22 23 |
# File 'lib/soundcloud2000/models/collection.rb', line 19 def clear @page = 0 @rows = [] @loaded = false end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/soundcloud2000/models/collection.rb', line 25 def each(&block) @rows.each(&block) end |
#replace(rows) ⇒ Object
29 30 31 32 33 |
# File 'lib/soundcloud2000/models/collection.rb', line 29 def replace(rows) clear @rows = rows events.trigger(:replace) end |