Class: Soundcloud9000::Models::Collection
- Inherits:
-
Object
- Object
- Soundcloud9000::Models::Collection
- Includes:
- Enumerable
- Defined in:
- lib/soundcloud9000/models/collection.rb
Overview
stores the tracks displayed in the track controller
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.
10 11 12 13 14 |
# File 'lib/soundcloud9000/models/collection.rb', line 10 def initialize(client) @client = client @events = Events.new clear end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
8 9 10 |
# File 'lib/soundcloud9000/models/collection.rb', line 8 def events @events end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
8 9 10 |
# File 'lib/soundcloud9000/models/collection.rb', line 8 def page @page end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
8 9 10 |
# File 'lib/soundcloud9000/models/collection.rb', line 8 def rows @rows end |
Instance Method Details
#[](*args) ⇒ Object
16 17 18 |
# File 'lib/soundcloud9000/models/collection.rb', line 16 def [](*args) @rows[*args] end |
#append(rows) ⇒ Object
36 37 38 39 |
# File 'lib/soundcloud9000/models/collection.rb', line 36 def append(rows) @rows += rows events.trigger(:append) end |
#clear ⇒ Object
20 21 22 23 24 |
# File 'lib/soundcloud9000/models/collection.rb', line 20 def clear @page = 0 @rows = [] @loaded = false end |
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/soundcloud9000/models/collection.rb', line 26 def each(&block) @rows.each(&block) end |
#replace(rows) ⇒ Object
30 31 32 33 34 |
# File 'lib/soundcloud9000/models/collection.rb', line 30 def replace(rows) clear @rows = rows events.trigger(:replace) end |