Class: I18nPhoneNumbers::PhoneNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_phone_numbers/phone_number.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_codeObject

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_sourceObject

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_zeroObject

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_numberObject

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_codeObject

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_inputObject

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