Class: TelephoneNumber::Number
- Inherits:
-
Object
- Object
- TelephoneNumber::Number
- Extended by:
- Forwardable
- Defined in:
- lib/telephone_number/number.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#geo_locator ⇒ Object
readonly
Returns the value of attribute geo_locator.
-
#original_number ⇒ Object
readonly
Returns the value of attribute original_number.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#time_zone_detector ⇒ Object
readonly
Returns the value of attribute time_zone_detector.
Instance Method Summary collapse
-
#initialize(number, country = nil) ⇒ Number
constructor
A new instance of Number.
- #location(locale = :en) ⇒ Object
- #timezone ⇒ Object
Constructor Details
#initialize(number, country = nil) ⇒ Number
Returns a new instance of Number.
10 11 12 13 14 15 |
# File 'lib/telephone_number/number.rb', line 10 def initialize(number, country = nil) @original_number = TelephoneNumber.sanitize(number) @country = country ? Country.find(country) : detect_country @parser = Parser.new(self) @formatter = Formatter.new(self) end |
Instance Attribute Details
#country ⇒ Object (readonly)
Returns the value of attribute country.
5 6 7 |
# File 'lib/telephone_number/number.rb', line 5 def country @country end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
5 6 7 |
# File 'lib/telephone_number/number.rb', line 5 def formatter @formatter end |
#geo_locator ⇒ Object (readonly)
Returns the value of attribute geo_locator.
5 6 7 |
# File 'lib/telephone_number/number.rb', line 5 def geo_locator @geo_locator end |
#original_number ⇒ Object (readonly)
Returns the value of attribute original_number.
5 6 7 |
# File 'lib/telephone_number/number.rb', line 5 def original_number @original_number end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
5 6 7 |
# File 'lib/telephone_number/number.rb', line 5 def parser @parser end |
#time_zone_detector ⇒ Object (readonly)
Returns the value of attribute time_zone_detector.
5 6 7 |
# File 'lib/telephone_number/number.rb', line 5 def time_zone_detector @time_zone_detector end |
Instance Method Details
#location(locale = :en) ⇒ Object
17 18 19 20 21 |
# File 'lib/telephone_number/number.rb', line 17 def location(locale = :en) return if !country || !valid? @geo_locator ||= GeoLocator.new(self, locale) @geo_locator.location end |
#timezone ⇒ Object
23 24 25 26 27 |
# File 'lib/telephone_number/number.rb', line 23 def timezone return if !country || !valid? @time_zone_detector ||= TimeZoneDetector.new(self) @time_zone_detector.detect_timezone end |