Class: AdWords::Location

Inherits:
Struct
  • Object
show all
Defined in:
lib/adwords_location/location.rb

Constant Summary collapse

POSTAL_CODE =
'Postal Code'
US =
'US'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#canonical_nameObject

Returns the value of attribute canonical_name

Returns:

  • (Object)

    the current value of canonical_name



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def canonical_name
  @canonical_name
end

#country_codeObject

Returns the value of attribute country_code

Returns:

  • (Object)

    the current value of country_code



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def country_code
  @country_code
end

#criteria_idObject

Returns the value of attribute criteria_id

Returns:

  • (Object)

    the current value of criteria_id



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def criteria_id
  @criteria_id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id

Returns:

  • (Object)

    the current value of parent_id



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def parent_id
  @parent_id
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def status
  @status
end

#target_typeObject

Returns the value of attribute target_type

Returns:

  • (Object)

    the current value of target_type



6
7
8
# File 'lib/adwords_location/location.rb', line 6

def target_type
  @target_type
end

Class Method Details

.allObject



24
25
26
27
28
# File 'lib/adwords_location/location.rb', line 24

def self.all
  data.drop(1).map do |row|
    AdWords::Location.new(row[0].to_i, row[1], row[2], row[3].to_i, row[4], row[5], row[6])
  end
end

Instance Method Details

#descriptionObject



11
12
13
# File 'lib/adwords_location/location.rb', line 11

def description
  "#{canonical_name} (#{target_type})"
end

#postal_codeObject



15
16
17
18
# File 'lib/adwords_location/location.rb', line 15

def postal_code
  raise "Call postal_code the the record targeting type is: #{target_type}" unless target_type == POSTAL_CODE
  name.rjust(5,'0')
end

#us_postal_code?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/adwords_location/location.rb', line 20

def us_postal_code?
  target_type == POSTAL_CODE and country_code == US
end