Class: TelephoneNumber::Parser
- Inherits:
-
Object
- Object
- TelephoneNumber::Parser
- Defined in:
- lib/telephone_number/parser.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#normalized_number ⇒ Object
readonly
Returns the value of attribute normalized_number.
-
#original_number ⇒ Object
readonly
Returns the value of attribute original_number.
Instance Method Summary collapse
-
#initialize(number_obj) ⇒ Parser
constructor
A new instance of Parser.
- #valid?(keys = []) ⇒ Boolean
- #valid_types ⇒ Object
Constructor Details
#initialize(number_obj) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 9 |
# File 'lib/telephone_number/parser.rb', line 5 def initialize(number_obj) @original_number = number_obj.original_number @country = number_obj.country @normalized_number = build_normalized_number if @country end |
Instance Attribute Details
#country ⇒ Object (readonly)
Returns the value of attribute country.
3 4 5 |
# File 'lib/telephone_number/parser.rb', line 3 def country @country end |
#normalized_number ⇒ Object (readonly)
Returns the value of attribute normalized_number.
3 4 5 |
# File 'lib/telephone_number/parser.rb', line 3 def normalized_number @normalized_number end |
#original_number ⇒ Object (readonly)
Returns the value of attribute original_number.
3 4 5 |
# File 'lib/telephone_number/parser.rb', line 3 def original_number @original_number end |
Instance Method Details
#valid?(keys = []) ⇒ Boolean
15 16 17 |
# File 'lib/telephone_number/parser.rb', line 15 def valid?(keys = []) keys.empty? ? !valid_types.empty? : !(valid_types & keys.map(&:to_sym)).empty? end |
#valid_types ⇒ Object
11 12 13 |
# File 'lib/telephone_number/parser.rb', line 11 def valid_types @valid_types ||= generate_valid_types(normalized_number) end |