Class: Yieldmanager::Report
- Inherits:
-
Object
- Object
- Yieldmanager::Report
- Defined in:
- lib/yieldmanager/report.rb
Overview
This is the data object for all reportware requests.
The #pull method is typically called by Yieldmanager::Client#pull_report.
Data is returned as an array that can be accessed either by index or by column name:
report.headers # => ['advertiser_name','seller_imps']
report.data[0][0] # => "Bob's Ads"
report.data[0].by_name('advertiser_name') # => "Bob's Ads"
report.data[0].by_name(:advertiser_name) # => "Bob's Ads"
Column order is stored in the headers array.
Defined Under Namespace
Classes: ReportRow
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
- #add_row(row_data) ⇒ Object
-
#initialize ⇒ Report
constructor
A new instance of Report.
- #pull(token, report, xml) ⇒ Object
- #to_hashes ⇒ Object
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
31 32 33 34 |
# File 'lib/yieldmanager/report.rb', line 31 def initialize self.headers = [] self.data = [] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
29 30 31 |
# File 'lib/yieldmanager/report.rb', line 29 def data @data end |
#headers ⇒ Object
Returns the value of attribute headers.
29 30 31 |
# File 'lib/yieldmanager/report.rb', line 29 def headers @headers end |
Instance Method Details
#add_row(row_data) ⇒ Object
42 43 44 45 46 |
# File 'lib/yieldmanager/report.rb', line 42 def add_row row_data row = ReportRow.new(self) row_data.each { |ele| row << ele } data << row end |
#pull(token, report, xml) ⇒ Object
36 37 38 39 40 |
# File 'lib/yieldmanager/report.rb', line 36 def pull token, report, xml report_token = request_report_token token, report, xml report_url = retrieve_report_url token, report, report_token retrieve_data report_url end |
#to_hashes ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/yieldmanager/report.rb', line 48 def to_hashes hashes = [] data.each do |row| row_hash = {} row.each_with_index do |ele,idx| row_hash[headers[idx]] = ele end hashes << row_hash end hashes end |