Class: Biggs::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/biggs/format.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iso_code) ⇒ Format

Returns a new instance of Format.



5
6
7
8
9
10
# File 'lib/biggs/format.rb', line 5

def initialize(iso_code)
  @iso_code      = iso_code.to_s.downcase
  @country       = Biggs.country[@iso_code]
  @country_name  = @country ? @country.name : nil
  @format_string = @country ? @country.address_format : nil
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



3
4
5
# File 'lib/biggs/format.rb', line 3

def country
  @country
end

#country_nameObject (readonly)

Returns the value of attribute country_name.



3
4
5
# File 'lib/biggs/format.rb', line 3

def country_name
  @country_name
end

#format_stringObject (readonly)

Returns the value of attribute format_string.



3
4
5
# File 'lib/biggs/format.rb', line 3

def format_string
  @format_string
end

#iso_codeObject (readonly)

Returns the value of attribute iso_code.



3
4
5
# File 'lib/biggs/format.rb', line 3

def iso_code
  @iso_code
end

Class Method Details

.find(iso_code) ⇒ Object



13
14
15
# File 'lib/biggs/format.rb', line 13

def find(iso_code)
  entries_cache[iso_code] ||= new(iso_code)
end