Class: Soundcloud2000::Models::Collection

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

Direct Known Subclasses

TrackCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#eventsObject (readonly)

Returns the value of attribute events.



7
8
9
# File 'lib/soundcloud2000/models/collection.rb', line 7

def events
  @events
end

#pageObject (readonly)

Returns the value of attribute page.



7
8
9
# File 'lib/soundcloud2000/models/collection.rb', line 7

def page
  @page
end

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

#clearObject



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