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
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity.
-
#initialize(response) ⇒ TrafficHistory
constructor
A new instance of TrafficHistory.
-
#setup_data!(response) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
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.
8 9 10 11 |
# File 'lib/awis/models/traffic_history.rb', line 8 def initialize(response) @historical_data = [] setup_data! loading_response(response) end |
Instance Attribute Details
#historical_data ⇒ Object
Returns the value of attribute historical_data.
6 7 8 |
# File 'lib/awis/models/traffic_history.rb', line 6 def historical_data @historical_data end |
#range ⇒ Object
Returns the value of attribute range.
6 7 8 |
# File 'lib/awis/models/traffic_history.rb', line 6 def range @range end |
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/awis/models/traffic_history.rb', line 6 def site @site end |
#start ⇒ Object
Returns the value of attribute start.
6 7 8 |
# File 'lib/awis/models/traffic_history.rb', line 6 def start @start end |
Instance Method Details
#base_node_name ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity
53 54 55 |
# File 'lib/awis/models/traffic_history.rb', line 53 def base_node_name "#{root_node_name}/aws:TrafficHistory/aws:HistoricalData/aws:Data" end |
#setup_data!(response) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
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 44 45 46 47 48 |
# File 'lib/awis/models/traffic_history.rb', line 16 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 |