Class: TinySong
Constant Summary collapse
- API_KEY =
"a7a9aeb495388ed7bcd8086fa414a775"
Instance Method Summary collapse
-
#initialize ⇒ TinySong
constructor
A new instance of TinySong.
- #play_song ⇒ Object
Constructor Details
#initialize ⇒ TinySong
Returns a new instance of TinySong.
8 9 |
# File 'lib/pias.rb', line 8 def initialize end |
Instance Method Details
#play_song ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pias.rb', line 11 def play_song return 'Please enter a song' if ARGV.count == 0 song = ARGV.join "+" params= {:query => {:format => "json", :key => API_KEY}} response=self.class.get("http://tinysong.com/a/#{song}", params) url=response.parsed_response.delete("\\") if url =~ /tinysong\.com/ puts "Play it again Sam #{url}" `open #{url}` else puts "Error accessing API, try again later." end end |