Class: I18nPhoneNumbers::PhoneNumber
- Inherits:
-
Object
- Object
- I18nPhoneNumbers::PhoneNumber
- Defined in:
- lib/i18n_phone_numbers/phone_number.rb
Instance Attribute Summary collapse
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#country_code_source ⇒ Object
Returns the value of attribute country_code_source.
-
#italian_leading_zero ⇒ Object
Returns the value of attribute italian_leading_zero.
-
#national_number ⇒ Object
Returns the value of attribute national_number.
-
#preferred_domestic_carrier_code ⇒ Object
Returns the value of attribute preferred_domestic_carrier_code.
-
#raw_input ⇒ Object
Returns the value of attribute raw_input.
Instance Method Summary collapse
-
#equals(other) ⇒ Object
for tests purpose.
-
#initialize(attrs = {}) ⇒ PhoneNumber
constructor
A new instance of PhoneNumber.
Constructor Details
#initialize(attrs = {}) ⇒ PhoneNumber
Returns a new instance of PhoneNumber.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 12 def initialize(attrs = {}) attrs.each_pair { |key, value| if [:raw_input, :country_code, :country_code_source, :national_number, :preferred_domestic_carrier_code, :italian_leading_zero].include?(key.to_sym) self.send(key.to_s + "=", value) end } end |
Instance Attribute Details
#country_code ⇒ Object
Returns the value of attribute country_code.
5 6 7 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 5 def country_code @country_code end |
#country_code_source ⇒ Object
Returns the value of attribute country_code_source.
5 6 7 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 5 def country_code_source @country_code_source end |
#italian_leading_zero ⇒ Object
Returns the value of attribute italian_leading_zero.
5 6 7 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 5 def italian_leading_zero @italian_leading_zero end |
#national_number ⇒ Object
Returns the value of attribute national_number.
5 6 7 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 5 def national_number @national_number end |
#preferred_domestic_carrier_code ⇒ Object
Returns the value of attribute preferred_domestic_carrier_code.
5 6 7 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 5 def preferred_domestic_carrier_code @preferred_domestic_carrier_code end |
#raw_input ⇒ Object
Returns the value of attribute raw_input.
5 6 7 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 5 def raw_input @raw_input end |
Instance Method Details
#equals(other) ⇒ Object
for tests purpose
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/i18n_phone_numbers/phone_number.rb', line 26 def equals(other) return false if !(self.class === other) # not the same class [:country_code, :national_number, :italian_leading_zero].each do |attribute| return false if self.send(attribute) != other.send(attribute) end return true end |