Class: Sem4r::AdGroupAd

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

Direct Known Subclasses

AdGroupMobileAd, AdGroupTextAd

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, &block) ⇒ AdGroupAd

Returns a new instance of AdGroupAd.



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

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

Instance Attribute Details

#ad_groupObject (readonly)

Returns the value of attribute ad_group.



62
63
64
# File 'lib/sem4r/ad_group_ad/ad_group_ad.rb', line 62

def ad_group
  @ad_group
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.from_element(ad_group, el) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/sem4r/ad_group_ad/ad_group_ad.rb', line 88

def self.from_element( ad_group, el )
  xml_type =       el.at_xpath("Ad.Type").text.strip
  case xml_type
  when TextAd
    AdGroupTextAd.from_element(ad_group, el)
  when MobileAd
    AdGroupMobileAd.from_element(ad_group, el)
  end
end

Instance Method Details

#idObject

try to save when accessing id



83
84
85
86
# File 'lib/sem4r/ad_group_ad/ad_group_ad.rb', line 83

def id
  save unless @id
  @id
end

#saved?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/sem4r/ad_group_ad/ad_group_ad.rb', line 78

def saved?
  !@id.nil?
end