Class: Sistrix::Monitoring::Report::Download

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/sistrix/monitoring/report/download.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @data, @error = nil, nil

  @options = {
    'project' => nil,
    'report' => nil,
    'date' => nil,
    'api_key' => Sistrix.config.api_key,
  }.merge(options)

  if Sistrix.config.proxy
    RestClient.proxy = Sistrix.config.proxy
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/sistrix/monitoring/report/download.rb', line 8

def data
  @data
end

#errorObject (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 = {})
  @options.merge!(options)

  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

Returns:

  • (Boolean)


44
45
46
# File 'lib/sistrix/monitoring/report/download.rb', line 44

def error?
  ! @error.nil?
end