Class: Nokaya::Apple

Inherits:
Basic
  • Object
show all
Defined in:
lib/nokaya/apple.rb

Direct Known Subclasses

AppStore, MusicStore

Instance Attribute Summary

Attributes inherited from Basic

#args, #filenames, #name, #options, #path, #type, #urls

Instance Method Summary collapse

Methods inherited from Basic

#get_basic, #name_files, #parse, #save

Constructor Details

#initialize(args, options) ⇒ Apple

Returns a new instance of Apple.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nokaya/apple.rb', line 6

def initialize args, options
  super(args, options)
  if options['ios']
    @entity = "software"
  elsif options['itunes']
    if options['album']
      @entity = 'album'
    else
      @entity = "musicTrack"
    end
  else
    @entity = "macSoftware"
  end
end

Instance Method Details

#create_url(terms) ⇒ Object



21
22
23
# File 'lib/nokaya/apple.rb', line 21

def create_url terms
  URI.parse("http://itunes.apple.com/search?term=#{CGI.escape(terms.join(" "))}&entity=#{@entity}")
end

#music_url(terms) ⇒ Object



25
26
27
28
29
# File 'lib/nokaya/apple.rb', line 25

def music_url terms
  url = "http://itunes.apple.com/search?entity=#{@entity}"
  terms.each {|term| url << "&term=#{CGI.escape(term)}"}
  URI.parse(url)
end