Class: TelephoneNumber::NumberFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/telephone_number/number_format.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_hash, country_prefix_formatting_rule) ⇒ NumberFormat

Returns a new instance of NumberFormat.



6
7
8
9
10
11
12
# File 'lib/telephone_number/number_format.rb', line 6

def initialize(data_hash, country_prefix_formatting_rule)
  @pattern = Regexp.new(data_hash[:pattern]) if data_hash[:pattern]
  @leading_digits = Regexp.new(data_hash[:leading_digits]) if data_hash[:leading_digits]
  @format = data_hash[:format]
  @intl_format = data_hash[:intl_format]
  @national_prefix_formatting_rule = data_hash[:national_prefix_formatting_rule] || country_prefix_formatting_rule
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



4
5
6
# File 'lib/telephone_number/number_format.rb', line 4

def format
  @format
end

#intl_formatObject (readonly)

Returns the value of attribute intl_format.



4
5
6
# File 'lib/telephone_number/number_format.rb', line 4

def intl_format
  @intl_format
end

#leading_digitsObject (readonly)

Returns the value of attribute leading_digits.



4
5
6
# File 'lib/telephone_number/number_format.rb', line 4

def leading_digits
  @leading_digits
end

#national_prefix_formatting_ruleObject (readonly)

Returns the value of attribute national_prefix_formatting_rule.



4
5
6
# File 'lib/telephone_number/number_format.rb', line 4

def national_prefix_formatting_rule
  @national_prefix_formatting_rule
end

#patternObject (readonly)

Returns the value of attribute pattern.



4
5
6
# File 'lib/telephone_number/number_format.rb', line 4

def pattern
  @pattern
end