Class: Spot::Base
- Inherits:
-
Object
- Object
- Spot::Base
- Defined in:
- lib/spot/base.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#available?(territory = nil) ⇒ Boolean
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: en.wikipedia.org/wiki/ISO_3166-1_alpha-2 Sweden => SE Norway => NO.
-
#href(type = "spotify") ⇒ Object
Returns a URL for the object type can contain the value “spotify” or “href” href => open.spotify.com/track/5DhDGwNXRPHsMApbtVKvFb spotify => spotify:track:5DhDGwNXRPHsMApbtVKvFb.
-
#initialize(args) ⇒ Base
constructor
A new instance of Base.
-
#popularity ⇒ Object
Returns a value from 0 to 1 The return type if float.
-
#to_s ⇒ Object
Returns a string representation of the item.
-
#valid? ⇒ Boolean
Is the object it self valid?.
Constructor Details
#initialize(args) ⇒ Base
Returns a new instance of Base.
7 8 9 |
# File 'lib/spot/base.rb', line 7 def initialize(args) args.keys.each { |name| instance_variable_set "@" + name.to_s.gsub(/[^a-z]/i, ''), args[name] } end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/spot/base.rb', line 5 def name @name end |
Instance Method Details
#available?(territory = nil) ⇒ Boolean
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: en.wikipedia.org/wiki/ISO_3166-1_alpha-2 Sweden => SE Norway => NO
21 22 23 |
# File 'lib/spot/base.rb', line 21 def available?(territory = nil) territories.include?(territory) end |
#href(type = "spotify") ⇒ Object
Returns a URL for the object type can contain the value “spotify” or “href” href => open.spotify.com/track/5DhDGwNXRPHsMApbtVKvFb spotify => spotify:track:5DhDGwNXRPHsMApbtVKvFb
29 30 31 |
# File 'lib/spot/base.rb', line 29 def href(type = "spotify") send("href_#{type}") end |
#popularity ⇒ Object
Returns a value from 0 to 1 The return type if float
40 41 42 |
# File 'lib/spot/base.rb', line 40 def popularity @_popularity ||= @popularity.to_f end |
#to_s ⇒ Object
Returns a string representation of the item
34 35 36 |
# File 'lib/spot/base.rb', line 34 def to_s not_implemented end |
#valid? ⇒ Boolean
Is the object it self valid?
12 13 14 |
# File 'lib/spot/base.rb', line 12 def valid? not_implemented end |