Class: HappyPhoneNumber::Formatter
- Inherits:
-
Object
- Object
- HappyPhoneNumber::Formatter
- Defined in:
- lib/happy_phone_number/formatter.rb
Overview
Internal: A simple facade which call the real formatter.
Instance Method Summary collapse
-
#format ⇒ Object
Internal: Call the real formatter.
-
#initialize(phone, type, country_or_mask, separator) ⇒ Formatter
constructor
Internal: Initialize the formatter facade.
Constructor Details
#initialize(phone, type, country_or_mask, separator) ⇒ Formatter
Internal: Initialize the formatter facade.
phone - A String phone number to format. type - :national | :international | :mask. country_or_mask - The country as Symbol or String in
ISO 3166-1-alpha-2, or a String mask.
separator - Optional, a String to separate groups of digits
the final result.
16 17 18 19 20 21 |
# File 'lib/happy_phone_number/formatter.rb', line 16 def initialize phone, type, country_or_mask, separator @phone = phone @type = type @country_or_mask = country_or_mask @separator = separator || ' ' end |
Instance Method Details
#format ⇒ Object
Internal: Call the real formatter.
Returns the String formatted phone number.
26 27 28 29 30 31 32 |
# File 'lib/happy_phone_number/formatter.rb', line 26 def format if @type == :mask use_mask else use_formatter end end |