Class: Adapi::ConstantData::Language

Inherits:
Adapi::ConstantData show all
Defined in:
lib/adapi/constant_data/language.rb

Constant Summary collapse

LANGUAGE_IDS =
{ :en => 1000, :de => 1001, :fr => 1002, :es => 1003,
  :it => 1004, :ja => 1005, :da => 1009, :nl => 1010, :fi => 1011, :ko => 1012,
  :no => 1013, :pt => 1014, :sv => 1015, :zh_CN => 1017, :zh_TW => 1018,
  :ar => 1019, :bg => 1020, :cs => 1021, :el => 1022, :hi => 1023, :hu => 1024,
  :id => 1025, :is => 1026, :iw => 1027, :lv => 1028, :lt => 1029, :pl => 1030,
  :ru => 1031, :ro => 1032, :sk => 1033, :sl => 1034, :sr => 1035, :uk => 1036,
  :tr => 1037, :ca => 1038, :hr => 1039, :vi => 1040, :ur => 1041, :tl => 1042,
  :et => 1043, :th => 1044
}

Constants inherited from Api

Api::API_EXCEPTIONS, Api::LOGGER

Instance Attribute Summary collapse

Attributes inherited from Api

#adwords, #params, #service, #status, #version, #xsi_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api

#[], #[]=, #attributes, #check_for_errors, create, #mutate, #new?, #persisted?, #store_errors, to_micro_units, #to_param, update

Constructor Details

#initialize(params = {}) ⇒ Language

Returns a new instance of Language.



28
29
30
31
32
33
# File 'lib/adapi/constant_data/language.rb', line 28

def initialize(params = {})
  @id = params[:id]
  @code = params[:code]

  super(params)
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



26
27
28
# File 'lib/adapi/constant_data/language.rb', line 26

def code
  @code
end

#idObject

Returns the value of attribute id.



26
27
28
# File 'lib/adapi/constant_data/language.rb', line 26

def id
  @id
end

Class Method Details

.find(code) ⇒ Object

Finds Language instance by language code or language id (numeric argument)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/adapi/constant_data/language.rb', line 37

def self.find(code)
  
  if code.is_a?(Integer)
    Language.new(
      :id => code,
      :code => LANGUAGE_IDS.find { |k,v| v == code }.first
    )

  else
    Language.new(
      :id => LANGUAGE_IDS[code.to_sym.downcase],
      :code => code.to_sym.downcase
    )
  end
end