Class: SwissMatch::Name
- Inherits:
-
String
- Object
- String
- SwissMatch::Name
- Defined in:
- lib/swissmatch/name.rb
Overview
Adds a couple of properties to the String class. These properties are relevant to the naming of Cantons, Communities and ZipCodes. They provide information about the language in which the name is, and which sequence number that name has.
Instance Attribute Summary collapse
-
#language ⇒ Symbol
readonly
The language of this name (:de, :fr, :it or :rt).
-
#sequence_number ⇒ Integer
readonly
The sequence number of this name.
Instance Method Summary collapse
-
#initialize(name, language, sequence_number = 0) ⇒ Name
constructor
A new instance of Name.
- #inspect ⇒ Object
- #to_a ⇒ Object
-
#to_hash ⇒ Hash
All properties of the name as a hash.
Constructor Details
#initialize(name, language, sequence_number = 0) ⇒ Name
Returns a new instance of Name.
25 26 27 28 29 |
# File 'lib/swissmatch/name.rb', line 25 def initialize(name, language, sequence_number=0) @language = language @sequence_number = sequence_number super(name.to_s) end |
Instance Attribute Details
#language ⇒ Symbol (readonly)
Returns The language of this name (:de, :fr, :it or :rt).
17 18 19 |
# File 'lib/swissmatch/name.rb', line 17 def language @language end |
#sequence_number ⇒ Integer (readonly)
Returns The sequence number of this name.
14 15 16 |
# File 'lib/swissmatch/name.rb', line 14 def sequence_number @sequence_number end |
Instance Method Details
#inspect ⇒ Object
47 48 49 |
# File 'lib/swissmatch/name.rb', line 47 def inspect "#{super}(#{@language}, #{@sequence_number})" end |
#to_a ⇒ Object
41 42 43 |
# File 'lib/swissmatch/name.rb', line 41 def to_a [to_s, @language, @sequence_number] end |
#to_hash ⇒ Hash
Returns All properties of the name as a hash.
33 34 35 36 37 38 39 |
# File 'lib/swissmatch/name.rb', line 33 def to_hash { :name => to_s, :language => @language, :sequence_number => @sequence_number, } end |