Class: Barometer::Query::Format
- Inherits:
-
Object
- Object
- Barometer::Query::Format
- Defined in:
- lib/barometer/formats/format.rb
Overview
Base Format Class
Fromats are used to determine if a query is of a certain format, how to convert to and from that format and what the country_code is for that format (if possible). Some formats require external Web Services to help in the converision. (ie :weather_id -> :geocode)
Direct Known Subclasses
Coordinates, Geocode, Postalcode, ShortZipcode, WeatherID, Zipcode, Query::Format::Icao
Defined Under Namespace
Classes: Coordinates, Geocode, Icao, Postalcode, ShortZipcode, WeatherID, Zipcode
Class Method Summary collapse
- .convertable_formats ⇒ Object
-
.converts?(query = nil) ⇒ Boolean
does the format support conversion from the given query?.
- .country_code(query = nil) ⇒ Object
- .format ⇒ Object
-
.is?(query = nil) ⇒ Boolean
is the query of this format?.
-
.is_a_query?(object = nil) ⇒ Boolean
is the object a Barometer::Query?.
-
.regex ⇒ Object
stubs.
-
.to(query = nil, country = nil) ⇒ Object
defaults.
Class Method Details
.convertable_formats ⇒ Object
22 |
# File 'lib/barometer/formats/format.rb', line 22 def self.convertable_formats; []; end |
.converts?(query = nil) ⇒ Boolean
does the format support conversion from the given query?
33 34 35 36 |
# File 'lib/barometer/formats/format.rb', line 33 def self.converts?(query=nil) return false unless is_a_query?(query) self.convertable_formats.include?(query.format) end |
.country_code(query = nil) ⇒ Object
21 |
# File 'lib/barometer/formats/format.rb', line 21 def self.country_code(query=nil); nil; end |
.format ⇒ Object
16 |
# File 'lib/barometer/formats/format.rb', line 16 def self.format; raise NotImplementedError; end |
.is?(query = nil) ⇒ Boolean
is the query of this format?
26 27 28 29 |
# File 'lib/barometer/formats/format.rb', line 26 def self.is?(query=nil) raise ArgumentError unless query.is_a?(String) return !(query =~ self.regex).nil? end |
.is_a_query?(object = nil) ⇒ Boolean
is the object a Barometer::Query?
40 41 42 43 |
# File 'lib/barometer/formats/format.rb', line 40 def self.is_a_query?(object=nil) return false unless object object.is_a?(Barometer::Query) end |
.regex ⇒ Object
stubs
15 |
# File 'lib/barometer/formats/format.rb', line 15 def self.regex; raise NotImplementedError; end |
.to(query = nil, country = nil) ⇒ Object
defaults
20 |
# File 'lib/barometer/formats/format.rb', line 20 def self.to(query=nil,country=nil); nil; end |