Class: Postrocktues::Feed

Inherits:
Object
  • Object
show all
Defined in:
lib/postrocktues/feed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#spotifyObject (readonly)

Returns the value of attribute spotify.



8
9
10
# File 'lib/postrocktues/feed.rb', line 8

def spotify
  @spotify
end

#urlObject (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_tracksObject 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_plaintextObject



23
24
25
# File 'lib/postrocktues/feed.rb', line 23

def tracks_as_plaintext
  @plaintext_tracks ||= fetcher.tracks.map &:to_s
end