Class: Yahoo::AdsEstimates
- Inherits:
-
Object
- Object
- Yahoo::AdsEstimates
- Defined in:
- lib/yahoo/ads_estimates.rb
Instance Attribute Summary collapse
-
#budgets ⇒ Object
readonly
Returns the value of attribute budgets.
-
#clicks ⇒ Object
readonly
Returns the value of attribute clicks.
-
#impressions ⇒ Object
readonly
Returns the value of attribute impressions.
-
#keyword ⇒ Object
readonly
Returns the value of attribute keyword.
-
#max_cpcs ⇒ Object
readonly
Returns the value of attribute max_cpcs.
Instance Method Summary collapse
-
#initialize(_keyword, _budgets = [1.0, 50.0]) ⇒ AdsEstimates
constructor
A new instance of AdsEstimates.
Constructor Details
#initialize(_keyword, _budgets = [1.0, 50.0]) ⇒ AdsEstimates
Returns a new instance of AdsEstimates.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/yahoo/ads_estimates.rb', line 12 def initialize(_keyword, _budgets=[1.0, 50.0]) @keyword = _keyword @budgets = _budgets @max_cpcs = [] @impressions = [] @clicks = [] @budgets.each do |budget| begin json = query(budget) result = JSON.parse(json) @impressions << result['impressions'].to_f @clicks << result['clicks'].to_f @max_cpcs << result['maxBid'].to_f rescue if defined?(RAILS_DEFAULT_LOGGER) RAILS_DEFAULT_LOGGER.info "Problem querying and parsing Yahoo, json: #{json}" else puts "Problem querying and parsing Yahoo, json: #{json}" end end end end |
Instance Attribute Details
#budgets ⇒ Object (readonly)
Returns the value of attribute budgets.
9 10 11 |
# File 'lib/yahoo/ads_estimates.rb', line 9 def budgets @budgets end |
#clicks ⇒ Object (readonly)
Returns the value of attribute clicks.
10 11 12 |
# File 'lib/yahoo/ads_estimates.rb', line 10 def clicks @clicks end |
#impressions ⇒ Object (readonly)
Returns the value of attribute impressions.
10 11 12 |
# File 'lib/yahoo/ads_estimates.rb', line 10 def impressions @impressions end |
#keyword ⇒ Object (readonly)
Returns the value of attribute keyword.
8 9 10 |
# File 'lib/yahoo/ads_estimates.rb', line 8 def keyword @keyword end |
#max_cpcs ⇒ Object (readonly)
Returns the value of attribute max_cpcs.
10 11 12 |
# File 'lib/yahoo/ads_estimates.rb', line 10 def max_cpcs @max_cpcs end |