Class: Bandcamp::Track

Inherits:
Object
  • Object
show all
Includes:
Associated, Methodical
Defined in:
lib/bandcamp/track.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Track

Returns a new instance of Track.



12
13
14
15
# File 'lib/bandcamp/track.rb', line 12

def initialize attrs
  @attrs_hash = attrs
  to_methods @attrs_hash
end

Instance Method Details

#albumObject



29
30
31
# File 'lib/bandcamp/track.rb', line 29

def album
  retrieve_associated :album
end

#bandObject



25
26
27
# File 'lib/bandcamp/track.rb', line 25

def band
  retrieve_associated :band
end

#free?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/bandcamp/track.rb', line 21

def free?
  downloadable == 1 ? true : false
end

#paid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/bandcamp/track.rb', line 17

def paid?
  downloadable == 2 ? true : false
end

#to_jsonObject



33
34
35
# File 'lib/bandcamp/track.rb', line 33

def to_json
  MultiJson.encode @attrs_hash
end