Sha256: 8f625ae5934fc7501b3593214b2b479a97198c4246baa00014dce26ae6eccff4
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
require "abstract" module SpotContainer class Base attr_reader :name def initialize(args) args.keys.each { |name| instance_variable_set "@" + name.to_s.gsub(/[^a-z]/i, ''), args[name] } end # Is the object it self valid? def valid? not_implemented end # Is the object available in {territory}? # Where {territory} can be any string representation of the ISO 3166-1 alpha-2 table # Read more about it here: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 # Sweden => SE # Norway => NO def available?(territory = nil) territories.include?(territory) end # Returns a URL for the object # {type} can contain the value "spotify" or "href" # href => http://open.spotify.com/track/5DhDGwNXRPHsMApbtVKvFb # spotify => spotify:track:5DhDGwNXRPHsMApbtVKvFb def href(type = "spotify") send("href_#{type}") end # Returns a string representation of the item def to_s not_implemented end # Returns a value from 0 to 1 # The return type if float def popularity @_popularity ||= @popularity.to_f end protected def territories not_implemented end private def href_http "http://open.spotify.com/#{$1}/#{$2}" if href_spotify.to_s =~ /spotify:(\w+):(\w+)/ end def href_spotify @href end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
spot-0.1.4 | lib/spot/base.rb |
spot-0.1.3 | lib/spot/base.rb |
spot-0.1.2 | lib/spot/base.rb |
spot-0.1.1 | lib/spot/base.rb |