Class: BlueConductor::Producer
- Inherits:
-
Object
- Object
- BlueConductor::Producer
- Defined in:
- lib/blue_conductor/producer.rb
Instance Attribute Summary collapse
-
#band ⇒ Object
readonly
Returns the value of attribute band.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#request ⇒ Object
Returns the value of attribute request.
-
#songs ⇒ Object
readonly
Returns the value of attribute songs.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url_generator ⇒ Object
Returns the value of attribute url_generator.
Instance Method Summary collapse
-
#initialize(band, record_title) ⇒ Producer
constructor
A new instance of Producer.
- #record! ⇒ Object
Constructor Details
#initialize(band, record_title) ⇒ Producer
Returns a new instance of Producer.
6 7 8 9 10 11 12 |
# File 'lib/blue_conductor/producer.rb', line 6 def initialize(band, record_title) @band = band @title = record_title @songs = nil @image = '' @error = '' end |
Instance Attribute Details
#band ⇒ Object (readonly)
Returns the value of attribute band.
3 4 5 |
# File 'lib/blue_conductor/producer.rb', line 3 def band @band end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
3 4 5 |
# File 'lib/blue_conductor/producer.rb', line 3 def error @error end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/blue_conductor/producer.rb', line 3 def image @image end |
#parser ⇒ Object
Returns the value of attribute parser.
4 5 6 |
# File 'lib/blue_conductor/producer.rb', line 4 def parser @parser end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/blue_conductor/producer.rb', line 4 def request @request end |
#songs ⇒ Object (readonly)
Returns the value of attribute songs.
3 4 5 |
# File 'lib/blue_conductor/producer.rb', line 3 def songs @songs end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/blue_conductor/producer.rb', line 3 def title @title end |
#url_generator ⇒ Object
Returns the value of attribute url_generator.
4 5 6 |
# File 'lib/blue_conductor/producer.rb', line 4 def url_generator @url_generator end |
Instance Method Details
#record! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/blue_conductor/producer.rb', line 14 def record! url = url_generator.generate(self) html = request.fetch(url) tracklist = parser.parse(html) if tracklist.nil? || tracklist.empty? @error = 'The album requested is not available || there was a spelling error' else @image = parser.parse_image(html) @songs = tracklist.map do |song| BlueConductor.song_for(@band, song) end end self end |