Sha256: 103b3bf9ceb650db226b3d7a43564b2f7a209609f41141132a70717cdb84947b

Contents?: true

Size: 702 Bytes

Versions: 5

Compression:

Stored size: 702 Bytes

Contents

# encoding: utf-8
module Nokaya

  class Apple < Basic

    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

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

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

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nokaya-0.1.6 lib/nokaya/apple.rb
nokaya-0.1.5 lib/nokaya/apple.rb
nokaya-0.1.4 lib/nokaya/apple.rb
nokaya-0.1.3 lib/nokaya/apple.rb
nokaya-0.1.2 lib/nokaya/apple.rb