Class: CodecoreJukebox::Connector
- Inherits:
-
Object
- Object
- CodecoreJukebox::Connector
- Defined in:
- lib/codecore_jukebox/connector.rb
Constant Summary collapse
- DEFAULT_URL =
"https://codecore-jukebox.herokuapp.com/"
Instance Method Summary collapse
-
#initialize(url = DEFAULT_URL) ⇒ Connector
constructor
A new instance of Connector.
- #send(name, notes, bpm = nil) ⇒ Object
Constructor Details
#initialize(url = DEFAULT_URL) ⇒ Connector
Returns a new instance of Connector.
8 9 10 |
# File 'lib/codecore_jukebox/connector.rb', line 8 def initialize(url = DEFAULT_URL) @url = url end |
Instance Method Details
#send(name, notes, bpm = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/codecore_jukebox/connector.rb', line 12 def send(name, notes, bpm=nil) unless notes.is_a? Array puts Cowsay.say("Oooops! The second argument must be an Array of Hashes!") return end notes_json = JSON.generate(notes) response = conn.post '/songs', {name: name, notes_json: notes_json, bpm: bpm} print_response(response.status) end |