Class: Libphonenumber
- Inherits:
-
Object
- Object
- Libphonenumber
- Defined in:
- lib/libphonenumber-execjs/version.rb,
lib/libphonenumber-execjs/libphonenumber.rb
Defined Under Namespace
Classes: Simple
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #extractPossibleNumber(str = "") ⇒ Object
-
#initialize ⇒ Libphonenumber
constructor
A new instance of Libphonenumber.
- #normalize(str = "") ⇒ Object
- #parse(str = "", default_region = "ZZ") ⇒ Object
- #simple ⇒ Object
Constructor Details
#initialize ⇒ Libphonenumber
Returns a new instance of Libphonenumber.
5 6 7 |
# File 'lib/libphonenumber-execjs/libphonenumber.rb', line 5 def initialize @context = ExecJS.compile(File.read(File.join(File.dirname(__FILE__), "..", "..", "support", "libphonenumber.js"))) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/libphonenumber-execjs/libphonenumber.rb', line 3 def context @context end |
Instance Method Details
#extractPossibleNumber(str = "") ⇒ Object
9 10 11 |
# File 'lib/libphonenumber-execjs/libphonenumber.rb', line 9 def extractPossibleNumber(str="") context.call "i18n.phonenumbers.PhoneNumberUtil.extractPossibleNumber", str end |
#normalize(str = "") ⇒ Object
13 14 15 |
# File 'lib/libphonenumber-execjs/libphonenumber.rb', line 13 def normalize(str="") context.call "i18n.phonenumbers.PhoneNumberUtil.normalize", str end |
#parse(str = "", default_region = "ZZ") ⇒ Object
17 18 19 |
# File 'lib/libphonenumber-execjs/libphonenumber.rb', line 17 def parse(str="", default_region="ZZ") context.call "i18n.phonenumbers.PhoneNumberUtil.getInstance().parse", str, default_region end |
#simple ⇒ Object
21 22 23 |
# File 'lib/libphonenumber-execjs/libphonenumber.rb', line 21 def simple @simple ||= Simple.new(self) end |