class SwissMatch::Canton

Represents a swiss canton.

Attributes

license_tag[R]

@return [String]

The two letter abbreviation of the cantons name as used on license plates.

Public Class Methods

new(license_tag, name, name_de, name_fr, name_it, name_rt) click to toggle source

@param [String] license_tag

The two letter abbreviation of the cantons name as used on license plates.

@param [String] name

The official name of the canton in the local language.

@param [String] name_de

The official name of the canton in german.

@param [String] name_fr

The official name of the canton in french.

@param [String] name_it

The official name of the canton in italian.

@param [String] name_rt

The official name of the canton in rhaeto-romanic.
# File lib/swissmatch/canton.rb, line 26
def initialize(license_tag, name, name_de, name_fr, name_it, name_rt)
  @license_tag  = license_tag
  @name         = name
  @names        = {
    :de => name_de,
    :fr => name_fr,
    :it => name_it,
    :rt => name_rt,
  }
end

Public Instance Methods

eql?(other) click to toggle source

@private @see Object#eql?

# File lib/swissmatch/canton.rb, line 74
def eql?(other)
  self.class == other.class && @license_tag == other.license_tag
end
hash() click to toggle source

@private @see Object#hash

# File lib/swissmatch/canton.rb, line 68
def hash
  [self.class, @license_tag].hash
end
inspect() click to toggle source

@return [String] @see Object#inspect

# File lib/swissmatch/canton.rb, line 80
def inspect
  sprintf "\#<%s:%014x %s>", self.class, object_id, self
end
name(language=nil) click to toggle source

The name of the canton. If no language is passed, the local language is used.

@param [Symbol, nil] language

One of nil, :de, :fr, :it or :rt
# File lib/swissmatch/canton.rb, line 41
def name(language=nil)
  language ? @names[language] : @name
end
Also aliased as: to_s
names() click to toggle source

@return [Array<String>]

The name of this zip code in all languages (only unique names)
# File lib/swissmatch/canton.rb, line 47
def names
  @names.values.uniq
end
to_hash() click to toggle source

@return [Hash]

All properties of the canton as a hash.
# File lib/swissmatch/canton.rb, line 53
def to_hash
  {
    :name         => @name,
    :name_de      => @names[:de],
    :name_fr      => @names[:fr],
    :name_it      => @names[:it],
    :name_rt      => @names[:rt],
    :license_tag  => @license_tag
  }
end
to_s(language=nil)
Alias for: name