Class: Sistrix::Monitoring::Report::Download
- Inherits:
-
Object
- Object
- Sistrix::Monitoring::Report::Download
- Includes:
- Base
- Defined in:
- lib/sistrix/monitoring/report/download.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(options = {}) ⇒ Download
constructor
A new instance of Download.
Methods included from Base
#base_uri, #fetch, #method_name
Constructor Details
#initialize(options = {}) ⇒ Download
Returns a new instance of Download.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sistrix/monitoring/report/download.rb', line 13 def initialize( = {}) @data, @error = nil, nil @options = { 'project' => nil, 'report' => nil, 'date' => nil, 'api_key' => Sistrix.config.api_key, }.merge() if Sistrix.config.proxy RestClient.proxy = Sistrix.config.proxy end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/sistrix/monitoring/report/download.rb', line 8 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/sistrix/monitoring/report/download.rb', line 9 def error @error end |
Instance Method Details
#call(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sistrix/monitoring/report/download.rb', line 29 def call( = {}) @options.merge!() response = RestClient.get(base_uri, { :params => @options }) begin xml = Nokogiri::XML(response.to_s) @error = Error.new(xml.xpath('/response/error').first) rescue Exception => ex @data = response.to_s end self end |
#error? ⇒ Boolean
44 45 46 |
# File 'lib/sistrix/monitoring/report/download.rb', line 44 def error? ! @error.nil? end |