Class: UncleKryon::Country

Inherits:
BaseIso show all
Defined in:
lib/unclekryon/iso/country.rb

Instance Attribute Summary collapse

Attributes inherited from BaseIso

#code, #name

Attributes inherited from BaseData

#updated_on

Instance Method Summary collapse

Methods inherited from BaseIso

#==, fix_name, flip_word_order, simplify_code, simplify_name

Methods inherited from BaseData

#initialize_copy, #max_updated_on, max_updated_on, #max_updated_on_s, max_updated_on_s, #update

Constructor Details

#initialize(row = nil) ⇒ Country

Returns a new instance of Country.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/unclekryon/iso/country.rb', line 32

def initialize(row=nil)
  super()

  @names = nil
  @codes = nil
  @alpha2_code = nil
  @alpha3_code = nil
  @region = nil

  if row.is_a?(Array)
    @name = self.class.simplify_name(row[0])
    @alpha2_code = row[2]
    @alpha3_code = row[3]

    @names = @name
    @code = @alpha3_code
    @codes = [@alpha3_code,@alpha2_code].compact.uniq
  end
end

Instance Attribute Details

#alpha2_codeObject (readonly)

Returns the value of attribute alpha2_code.



28
29
30
# File 'lib/unclekryon/iso/country.rb', line 28

def alpha2_code
  @alpha2_code
end

#alpha3_codeObject (readonly)

Returns the value of attribute alpha3_code.



29
30
31
# File 'lib/unclekryon/iso/country.rb', line 29

def alpha3_code
  @alpha3_code
end

#codesObject (readonly)

Returns the value of attribute codes.



27
28
29
# File 'lib/unclekryon/iso/country.rb', line 27

def codes
  @codes
end

#namesObject (readonly)

Returns the value of attribute names.



26
27
28
# File 'lib/unclekryon/iso/country.rb', line 26

def names
  @names
end

#regionObject (readonly)

Returns the value of attribute region.



30
31
32
# File 'lib/unclekryon/iso/country.rb', line 30

def region
  @region
end

Instance Method Details

#to_sObject



52
53
54
55
56
57
58
59
60
# File 'lib/unclekryon/iso/country.rb', line 52

def to_s
  s = '['.dup
  s << %Q("#{@name}","#{@names.join(';')}")
  s << %Q(,#{@code},"#{@codes.join(';')}",#{@alpha2_code},#{@alpha3_code})
  s << ",#{@region}"
  s << ']'

  return s
end