Class: Soundcloud9000::Models::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/soundcloud9000/models/collection.rb

Overview

stores the tracks displayed in the track controller

Direct Known Subclasses

TrackCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#eventsObject (readonly)

Returns the value of attribute events.



8
9
10
# File 'lib/soundcloud9000/models/collection.rb', line 8

def events
  @events
end

#pageObject (readonly)

Returns the value of attribute page.



8
9
10
# File 'lib/soundcloud9000/models/collection.rb', line 8

def page
  @page
end

#rowsObject (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

#clearObject



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