class Api::Connection
Public Instance Methods
common_name()
click to toggle source
# File lib/api/connection.rb, line 18 def common_name response["common_name"] end
invoke_if_valid_api_call() { || ... }
click to toggle source
# File lib/api/connection.rb, line 5 def invoke_if_valid_api_call(&block) yield if success_api_call? trigger_script_return end
options()
click to toggle source
# File lib/api/connection.rb, line 22 def options result = {} option_codes.reduce(result) do |options_with_codes, option_code| options_with_codes[option_code] = { option_class: Option::Repository.find_by_code(option_code), attributes: attributes_for_option(option_code) } options_with_codes end result end
trigger_script_return()
click to toggle source
# File lib/api/connection.rb, line 10 def trigger_script_return if success_api_call? exit 0 else exit 1 end end
Private Instance Methods
attributes_for_option(code)
click to toggle source
# File lib/api/connection.rb, line 54 def attributes_for_option(code) option_attributes[code] end
data()
click to toggle source
# File lib/api/connection.rb, line 37 def data { hostname: hostname, traffic_in: traffic_in, traffic_out: traffic_out, login: ENV['common_name'] } end
option_attributes()
click to toggle source
# File lib/api/connection.rb, line 50 def option_attributes response["option_attributes"] end
option_codes()
click to toggle source
# File lib/api/connection.rb, line 46 def option_codes response["options"] end
traffic_in()
click to toggle source
# File lib/api/connection.rb, line 58 def traffic_in ENV['bytes_received'] || "0" end
traffic_out()
click to toggle source
# File lib/api/connection.rb, line 62 def traffic_out ENV['bytes_sent'] || "0" end