Class: Sem4r::BiddableAdGroupCriterion

Inherits:
AdGroupCriterion show all
Defined in:
lib/sem4r/ad_group_criterion/ad_group_criterion.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AdGroupCriterion

#save, #saved?

Methods included from Sem4rSoap::SoapAttributes

#_from_element, #_to_s, #_to_xml, included

Constructor Details

#initialize(ad_group, &block) ⇒ BiddableAdGroupCriterion

Returns a new instance of BiddableAdGroupCriterion.



70
71
72
73
74
75
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 70

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

Class Method Details

.from_element(ad_group, el) ⇒ Object



81
82
83
84
85
86
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 81

def self.from_element(ad_group, el)
  new(ad_group) do
    criterion Criterion.from_element(ad_group, el.at_xpath("criterion"))
    bids      AdGroupCriterionBids.from_element(el.at_xpath("bids"))
  end
end

Instance Method Details

#_xml(t) ⇒ Object



88
89
90
91
92
93
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 88

def _xml(t)
  t.adGroupId   @ad_group.id
  # t.status "ENABLED"
  criterion.xml(t)
  @bids.xml(t) if @bids
end

#to_sObject



77
78
79
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 77

def to_s
  "biddable " + criterion.to_s
end

#to_xml(tag) ⇒ Object



103
104
105
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 103

def to_xml(tag)
  xml(Builder::XmlMarkup.new, tag)
end

#xml(t, tag = nil) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 95

def xml(t, tag = nil)
  if tag
    t.__send__(tag, {"xsi:type" => "BiddableAdGroupCriterion"}) { |t| _xml(t) }
  else
    _xml(t)
  end
end