Class: Sem4r::Criterion

Inherits:
Base
  • Object
show all
Defined in:
lib/sem4r/ad_group_criterion/criterion.rb

Direct Known Subclasses

CriterionKeyword, CriterionPlacement

Instance Attribute Summary collapse

Attributes inherited from Base

#adwords, #credentials, #service

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_counters

Methods included from Sem4rSoap::SoapAttributes

#_from_element, #_to_s, #_to_xml, included

Constructor Details

#initialize(ad_group) ⇒ Criterion

Returns a new instance of Criterion.



35
36
37
38
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 35

def initialize( ad_group )
  super( ad_group.adwords, ad_group.credentials )
  @ad_group = ad_group
end

Instance Attribute Details

#ad_groupObject (readonly)

Returns the value of attribute ad_group.



32
33
34
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 32

def ad_group
  @ad_group
end

#typeObject

Returns the value of attribute type.



33
34
35
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 33

def type
  @type
end

Class Method Details

.from_element(ad_group, el) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 48

def self.from_element( ad_group, el )
  xml_type = el.at_xpath("Criterion.Type").text.strip
  # klass = Module::const_get(type)
  # klass.from_element(ad_group, el)
  case xml_type
  when Keyword
    CriterionKeyword.from_element(ad_group, el)
  when Placement
    CriterionPlacement.from_element(ad_group, el)
  end
end

Instance Method Details

#ad_param(index = nil, text = nil, &block) ⇒ Object

ad params management



63
64
65
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 63

def ad_param(index = nil, text = nil, &block)
  ad_group.ad_param(self, index, text, &block)
end

#idObject



44
45
46
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 44

def id
  @id
end

#saved?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/sem4r/ad_group_criterion/criterion.rb', line 40

def saved?
  !@id.nil?
end