module GlobalPhone::Context
Attributes
db_path[RW]
Public Instance Methods
db()
click to toggle source
# File lib/global_phone/context.rb, line 7 def db @db ||= begin raise NoDatabaseError, "set `db_path=' first" unless db_path Database.load_file(db_path) end end
default_territory_name()
click to toggle source
# File lib/global_phone/context.rb, line 14 def default_territory_name @default_territory_name ||= :US end
default_territory_name=(territory_name)
click to toggle source
# File lib/global_phone/context.rb, line 18 def default_territory_name=(territory_name) @default_territory_name = territory_name.to_s.intern end
normalize(string, territory_name = default_territory_name)
click to toggle source
# File lib/global_phone/context.rb, line 26 def normalize(string, territory_name = default_territory_name) number = parse(string, territory_name) number.international_string if number end
parse(string, territory_name = default_territory_name)
click to toggle source
# File lib/global_phone/context.rb, line 22 def parse(string, territory_name = default_territory_name) db.parse(string, territory_name) end
validate(string, territory_name = default_territory_name)
click to toggle source
# File lib/global_phone/context.rb, line 31 def validate(string, territory_name = default_territory_name) number = parse(string, territory_name) number && number.valid? end