Class: Sem4r::TMonthlySearchVolumeAttribute

Inherits:
Object
  • Object
show all
Includes:
Sem4rSoap::SoapAttributes
Defined in:
lib/sem4r/targeting_idea/targeting_idea.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sem4rSoap::SoapAttributes

#_from_element, #_to_s, #_to_xml, included

Constructor Details

#initialize(&block) ⇒ TMonthlySearchVolumeAttribute

Returns a new instance of TMonthlySearchVolumeAttribute.



116
117
118
119
120
# File 'lib/sem4r/targeting_idea/targeting_idea.rb', line 116

def initialize(&block)
  if block_given?
    block.arity < 1 ? instance_eval(&block) : block.call(self)
  end
end

Class Method Details

.from_element(el) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/sem4r/targeting_idea/targeting_idea.rb', line 122

def self.from_element( el )
  historical_values = []
  el.children.each do |node|
    next if node.name == "Attribute.Type"
    historical_value = { :year => node.at_xpath("year").text,
      :month => node.at_xpath("month").text}
    historical_value.merge!(:count => node.at_xpath("count").text) if node.at_xpath("count")
    historical_values << historical_value
  end
  new do
    values historical_values
  end
end

Instance Method Details

#to_sObject



136
137
138
# File 'lib/sem4r/targeting_idea/targeting_idea.rb', line 136

def to_s
  "Values: #{values.inspect}"
end