Class: Georama::Parser
- Inherits:
-
Object
- Object
- Georama::Parser
- Defined in:
- lib/georama/parser.rb
Class Method Summary collapse
- .get_coordinates(params) ⇒ Object
- .get_metadata(params) ⇒ Object
- .is_google_maps_url?(url) ⇒ Boolean
- .url_type(path) ⇒ Object
Class Method Details
.get_coordinates(params) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/georama/parser.rb', line 22 def self.get_coordinates(params) split_params = params.split(",") {}.tap do |res| res[:latitude] = split_params[0].gsub("@", "").to_f res[:longitude] = split_params[1].to_f end end |
.get_metadata(params) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/georama/parser.rb', line 30 def self.(params) split_params = params.split(",") {}.tap do |res| res[:zoom] = split_params[-1][/\d+\.?\d*+?(?=z)/].to_f end end |
.is_google_maps_url?(url) ⇒ Boolean
4 5 6 7 8 9 10 |
# File 'lib/georama/parser.rb', line 4 def self.is_google_maps_url?(url) raise ArgumentError, "No url specified" if url.nil? parsed = URI.parse(url) is_google = parsed.host == "www.google.com" is_maps = parsed.path.start_with?("/maps/") is_google && is_maps end |
.url_type(path) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/georama/parser.rb', line 12 def self.url_type(path) raise ArgumentError, "No path specified" if path.nil? split_path = path.split("/") if split_path[2].start_with?("@") :general elsif split_path[2] == 'place' :place end end |