Class: Postrocktues::Feed
- Inherits:
-
Object
- Object
- Postrocktues::Feed
- Defined in:
- lib/postrocktues/feed.rb
Instance Attribute Summary collapse
-
#spotify ⇒ Object
readonly
Returns the value of attribute spotify.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Feed
constructor
A new instance of Feed.
- #list_tracks ⇒ Object (also: #tracks)
- #tracks_as_plaintext ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Feed
Returns a new instance of Feed.
10 11 12 13 |
# File 'lib/postrocktues/feed.rb', line 10 def initialize opts = {} @url = opts.fetch(:url) { fallback_url } @spotify = opts.fetch(:spotify) { fallback_spotify } end |
Instance Attribute Details
#spotify ⇒ Object (readonly)
Returns the value of attribute spotify.
8 9 10 |
# File 'lib/postrocktues/feed.rb', line 8 def spotify @spotify end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/postrocktues/feed.rb', line 8 def url @url end |
Instance Method Details
#list_tracks ⇒ Object Also known as: tracks
15 16 17 18 19 20 |
# File 'lib/postrocktues/feed.rb', line 15 def list_tracks @list_tracks ||= fetcher.queries.map do |t| track = spotify.search t Postrocktues::Track.new(track) unless track.nil? end end |
#tracks_as_plaintext ⇒ Object
23 24 25 |
# File 'lib/postrocktues/feed.rb', line 23 def tracks_as_plaintext @plaintext_tracks ||= fetcher.tracks.map &:to_s end |