Class: Sem4r::NegativeAdGroupCriterion

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) ⇒ NegativeAdGroupCriterion

Returns a new instance of NegativeAdGroupCriterion.



111
112
113
114
115
116
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 111

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



122
123
124
125
126
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 122

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

Instance Method Details

#_xml(t) ⇒ Object



131
132
133
134
135
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 131

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

#to_sObject



118
119
120
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 118

def to_s
  "negative " + criterion.to_s
end

#to_xml(tag) ⇒ Object



145
146
147
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 145

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

#xml(t, tag = nil) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/sem4r/ad_group_criterion/ad_group_criterion.rb', line 137

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