lib/smiten/core.rb in smiten-0.1.0 vs lib/smiten/core.rb in smiten-0.1.1
- old
+ new
@@ -25,15 +25,11 @@
calls.each_key do |api|
next if self.class.method_defined?(api)
self.class.define_method(api) do |args = {}|
args.each_pair do |key, value|
- if key == :timeout
- @url.timeout = value
- else
- send("#{key}=", value)
- end
+ send("#{key}=", value)
end
@url = calls[api][1].call
payload = get
{ kind: calls[api][0], payload: payload }
end
@@ -91,11 +87,11 @@
"#{meth}#{ResponseFormat}/#{developerId}/#{signature(meth)}/#{session_id}/#{timestamp}"
end
# Sets the champion_id on the connection and returns the connection
def for_champion(id)
- self.id = id
+ self.champion_id = id
yield(self)
end
# Sets the language on the connection and returns the connection
# Accepts either a language_code or the language name as a symbol
@@ -128,14 +124,14 @@
when result.status == 408
puts '* Server Timeout detected... Retrying'
when result.status == 504
puts '* Gateway Timeout detected... Retrying'
else
- raise(Error, "API Response Error:\n#{textify(result.body)}")
+ raise(Error, "API Response Error:#{textify(result.body)}")
end
end
- puts "* Timeout detected... Terminating after #{Time.new - start} seconds"
- ''
+ puts "* Timeout detected... Terminating after #{Time.now - start} seconds"
+ nil
end
def textify(html) # :nodoc:
return html unless html =~ /<head>/