Class: Metalive::Shoutcast
- Inherits:
-
Object
- Object
- Metalive::Shoutcast
- Includes:
- HTTParty
- Defined in:
- lib/metalive/shoutcast.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #base_uri ⇒ Object
- #headers ⇒ Object
-
#initialize(options = {}) ⇒ Shoutcast
constructor
A new instance of Shoutcast.
- #path ⇒ Object
- #query(song) ⇒ Object
- #update(metadata) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Shoutcast
Returns a new instance of Shoutcast.
8 9 10 11 |
# File 'lib/metalive/shoutcast.rb', line 8 def initialize( = {}) = { :port => 8000 }.update() .each_pair { |k,v| send("#{k}=", v) } end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/metalive/shoutcast.rb', line 6 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/metalive/shoutcast.rb', line 6 def port @port end |
#server ⇒ Object
Returns the value of attribute server.
6 7 8 |
# File 'lib/metalive/shoutcast.rb', line 6 def server @server end |
Instance Method Details
#base_uri ⇒ Object
17 18 19 |
# File 'lib/metalive/shoutcast.rb', line 17 def base_uri "http://#{server}:#{port}" end |
#headers ⇒ Object
25 26 27 |
# File 'lib/metalive/shoutcast.rb', line 25 def headers { "User-Agent" => "ShoutcastDSP (Mozilla Compatible)" } end |
#path ⇒ Object
21 22 23 |
# File 'lib/metalive/shoutcast.rb', line 21 def path "/admin.cgi" end |
#query(song) ⇒ Object
13 14 15 |
# File 'lib/metalive/shoutcast.rb', line 13 def query(song) { :mode => "updinfo", :song => song, :pass => password } end |
#update(metadata) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/metalive/shoutcast.rb', line 29 def update() song = (Hash === ? [:song] : .to_s) self.class.get path, :base_uri => base_uri, :query => query(song), :headers => headers true rescue => e false end |