Class: Awis::Models::TrafficHistory
- Defined in:
- lib/awis/models/traffic_history.rb
Instance Attribute Summary collapse
-
#historical_data ⇒ Object
Returns the value of attribute historical_data.
-
#range ⇒ Object
Returns the value of attribute range.
-
#site ⇒ Object
Returns the value of attribute site.
-
#start ⇒ Object
Returns the value of attribute start.
Attributes inherited from Base
#request_id, #response, #status_code
Instance Method Summary collapse
- #base_node_name ⇒ Object
-
#initialize(response) ⇒ TrafficHistory
constructor
A new instance of TrafficHistory.
- #setup_data!(response) ⇒ Object
Methods inherited from Base
#action_name, #loading_response, #relationship_collections, #root_node_name, #success?
Constructor Details
#initialize(response) ⇒ TrafficHistory
Returns a new instance of TrafficHistory.
6 7 8 9 |
# File 'lib/awis/models/traffic_history.rb', line 6 def initialize(response) @historical_data = [] setup_data! loading_response(response) end |
Instance Attribute Details
#historical_data ⇒ Object
Returns the value of attribute historical_data.
4 5 6 |
# File 'lib/awis/models/traffic_history.rb', line 4 def historical_data @historical_data end |
#range ⇒ Object
Returns the value of attribute range.
4 5 6 |
# File 'lib/awis/models/traffic_history.rb', line 4 def range @range end |
#site ⇒ Object
Returns the value of attribute site.
4 5 6 |
# File 'lib/awis/models/traffic_history.rb', line 4 def site @site end |
#start ⇒ Object
Returns the value of attribute start.
4 5 6 |
# File 'lib/awis/models/traffic_history.rb', line 4 def start @start end |
Instance Method Details
#base_node_name ⇒ Object
45 46 47 |
# File 'lib/awis/models/traffic_history.rb', line 45 def base_node_name "#{root_node_name}/aws:TrafficHistory/aws:HistoricalData/aws:Data" end |
#setup_data!(response) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/awis/models/traffic_history.rb', line 11 def setup_data!(response) datas = [] response.each_node do |node, path| text = node.inner_xml text = text.to_i if text.to_i.to_s === text text = nil if (text.class == String && text.empty?) if node.name == 'aws:RequestId' @request_id ||= text elsif node.name == 'aws:StatusCode' @status_code ||= text elsif node.name == 'aws:Range' @range ||= text elsif node.name == 'aws:Site' @site ||= text elsif node.name == 'aws:Start' @start ||= text elsif node.name == 'aws:Date' && path == "#{base_node_name}/aws:Date" datas << { date: text } elsif node.name == 'aws:PerMillion' && path == "#{base_node_name}/aws:PageViews/aws:PerMillion" datas << { page_views_per_million: text } elsif node.name == 'aws:PerUser' && path == "#{base_node_name}/aws:PageViews/aws:PerUser" datas << { page_views_per_user: text } elsif node.name == 'aws:Rank' && path == "#{base_node_name}/aws:Rank" datas << { rank: text } elsif node.name == 'aws:PerMillion' && path == "#{base_node_name}/aws:Reach/aws:PerMillion" datas << { reach_per_million: text } end end relationship_collections(@historical_data, datas, 5, HistoricalData) end |