Class: Moonshado::Sender
- Inherits:
-
Object
- Object
- Moonshado::Sender
- Defined in:
- lib/moonshado/sender.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http_open_timeout ⇒ Object
readonly
Returns the value of attribute http_open_timeout.
-
#http_read_timeout ⇒ Object
readonly
Returns the value of attribute http_read_timeout.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#secure ⇒ Object
readonly
Returns the value of attribute secure.
Instance Method Summary collapse
- #get(uri) ⇒ Object
-
#initialize(options = {}) ⇒ Sender
constructor
A new instance of Sender.
- #send_to_moonshado(data, uri) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Sender
Returns a new instance of Sender.
5 6 7 8 9 |
# File 'lib/moonshado/sender.rb', line 5 def initialize( = {}) [:protocol, :host, :port, :secure, :http_open_timeout, :http_read_timeout, :api_key].each do |option| instance_variable_set("@#{option}", [option]) end end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def api_key @api_key end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def host @host end |
#http_open_timeout ⇒ Object (readonly)
Returns the value of attribute http_open_timeout.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object (readonly)
Returns the value of attribute http_read_timeout.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def http_read_timeout @http_read_timeout end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def protocol @protocol end |
#secure ⇒ Object (readonly)
Returns the value of attribute secure.
3 4 5 |
# File 'lib/moonshado/sender.rb', line 3 def secure @secure end |
Instance Method Details
#get(uri) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/moonshado/sender.rb', line 22 def get(uri) http = RestClient::Resource.new( url(uri), :user => api_key, :timeout => http_read_timeout, :open_timeout => http_open_timeout ) response = http.get end |
#send_to_moonshado(data, uri) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/moonshado/sender.rb', line 11 def send_to_moonshado(data, uri) http = RestClient::Resource.new( url(uri), :user => api_key, :timeout => http_read_timeout, :open_timeout => http_open_timeout ) response = http.post(data) end |