Class: Sem4r::CriterionPlacement
- Inherits:
-
Criterion
show all
- Defined in:
- lib/sem4r/ad_group_criterion/criterion_placement.rb
Instance Attribute Summary
Attributes inherited from Criterion
#ad_group, #type
Attributes inherited from Base
#adwords, #credentials, #service
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Criterion
#ad_param, #id, #saved?
Methods inherited from Base
#add_counters
#_from_element, #_to_s, #_to_xml, included
Constructor Details
#initialize(ad_group, url = nil, &block) ⇒ CriterionPlacement
Returns a new instance of CriterionPlacement.
30
31
32
33
34
35
36
37
|
# File 'lib/sem4r/ad_group_criterion/criterion_placement.rb', line 30
def initialize(ad_group, url = nil, &block)
super( ad_group )
self.type = Placement
self.url = url unless url.nil?
if block_given?
block.arity < 1 ? instance_eval(&block) : block.call(self)
end
end
|
Class Method Details
.create(ad_group, &block) ⇒ Object
39
40
41
|
# File 'lib/sem4r/ad_group_criterion/criterion_placement.rb', line 39
def self.create(ad_group, &block)
new(ad_group, &block).save
end
|
.from_element(ad_group, el) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/sem4r/ad_group_criterion/criterion_placement.rb', line 43
def self.from_element( ad_group, el )
new(ad_group) do
@id = el.at_xpath("id").text.strip.to_i
url el.at_xpath("url").text.strip
end
end
|
Instance Method Details
#to_s ⇒ Object
50
51
52
|
# File 'lib/sem4r/ad_group_criterion/criterion_placement.rb', line 50
def to_s
"#{saved? ? id : 'unsaved'} #{type} #{url}"
end
|
#to_xml(tag) ⇒ Object
60
61
62
63
64
|
# File 'lib/sem4r/ad_group_criterion/criterion_placement.rb', line 60
def to_xml(tag)
builder = Builder::XmlMarkup.new
t = builder.tag!(tag, "xsi:type" => "CriterionKeyword")
xml(t)
end
|
#xml(t) ⇒ Object
54
55
56
57
58
|
# File 'lib/sem4r/ad_group_criterion/criterion_placement.rb', line 54
def xml(t)
t.criterion("xsi:type" => "#{type}") do |ad|
ad.url url
end
end
|