class Lyricli::Sources::Itunes

The source for iTunes

Attributes

name[RW]

Public Class Methods

enable() click to toggle source

The enable method should run all of the tasks needed to validate the source. In the case of Rdio it has to authenticate with OAuth.

# File lib/lyricli/sources/itunes.rb, line 14
def self.enable
  # Nothing to do
end
new() click to toggle source

Instantiates everything it needs to run.

# File lib/lyricli/sources/itunes.rb, line 19
def initialize
  @config = Configuration.instance
  @script = "current_song.scpt"
end
reset() click to toggle source

The reset method resets any configurations it may have

# File lib/lyricli/sources/itunes.rb, line 36
def self.reset
  # Nothing to do
end

Public Instance Methods

current_track() click to toggle source

The current_track method should return the name of the current artist and song. @return [Hash] A hash containing the current `:song` and `:artist`.

# File lib/lyricli/sources/itunes.rb, line 27
def current_track
  path_root = File.expand_path(File.dirname(__FILE__))
  path = File.join(path_root, @script)
  current = `osascript #{path}`
  current = current.split("<-SEP->")
  {:artist => current[0], :song => current[1]}
end