Class: Rubaiji::Connection
- Inherits:
-
Object
- Object
- Rubaiji::Connection
- Defined in:
- lib/rubaiji/connection.rb
Constant Summary collapse
- API_URL =
"http://netbaiji.com"- REPORT_INDEX_URL =
"/api/v2/report/"
Instance Attribute Summary collapse
-
#api_id ⇒ Object
readonly
Returns the value of attribute api_id.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #all_reports ⇒ Object
-
#initialize(params) ⇒ Connection
constructor
A new instance of Connection.
- #report(resource_uri) ⇒ Object
Constructor Details
#initialize(params) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 |
# File 'lib/rubaiji/connection.rb', line 7 def initialize(params) params.each do |k, v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Attribute Details
#api_id ⇒ Object (readonly)
Returns the value of attribute api_id.
3 4 5 |
# File 'lib/rubaiji/connection.rb', line 3 def api_id @api_id end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/rubaiji/connection.rb', line 3 def api_key @api_key end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
3 4 5 |
# File 'lib/rubaiji/connection.rb', line 3 def format @format end |
Instance Method Details
#all_reports ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rubaiji/connection.rb', line 13 def all_reports res = query REPORT_INDEX_URL report_set = Rubaiji::ReportSet.new(res["objects"]) report_set.(res["meta"]) report_set end |
#report(resource_uri) ⇒ Object
20 21 22 23 24 |
# File 'lib/rubaiji/connection.rb', line 20 def report(resource_uri) res = query resource_uri report = Rubaiji::Report.new(res) report end |