Class: WeatherGov::Identifier
- Inherits:
-
Object
- Object
- WeatherGov::Identifier
- Defined in:
- lib/weather_gov/identifier.rb,
lib/weather_gov/identifier.rb,
lib/weather_gov/identifier/alert.rb,
lib/weather_gov/identifier/point.rb,
lib/weather_gov/identifier/office.rb,
lib/weather_gov/identifier/problem.rb,
lib/weather_gov/identifier/station.rb,
lib/weather_gov/identifier/fire_zone.rb,
lib/weather_gov/identifier/gridpoint.rb,
lib/weather_gov/identifier/county_zone.rb,
lib/weather_gov/identifier/forecast_zone.rb
Direct Known Subclasses
Alert, CountyZone, FireZone, ForecastZone, Gridpoint, Office, Point, Problem, Station
Defined Under Namespace
Classes: Alert, CountyZone, FireZone, ForecastZone, Gridpoint, Office, Point, Problem, Station
Constant Summary collapse
- TYPES =
constants.map { |c| const_get(c) }.select { |c| c.superclass == self }
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(uri) ⇒ Identifier
constructor
A new instance of Identifier.
- #to_s ⇒ Object
Constructor Details
#initialize(uri) ⇒ Identifier
Returns a new instance of Identifier.
19 20 21 |
# File 'lib/weather_gov/identifier.rb', line 19 def initialize(uri) @uri = uri end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
5 6 7 |
# File 'lib/weather_gov/identifier.rb', line 5 def uri @uri end |
Class Method Details
.base_uri ⇒ Object
15 16 17 |
# File 'lib/weather_gov/identifier.rb', line 15 def self.base_uri API_BASE_URI end |
.parse(uri) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/weather_gov/identifier.rb', line 7 def self.parse(uri) TYPES.each do |type| return type.new(uri) if uri.start_with?(type.base_uri) end nil end |
Instance Method Details
#id ⇒ Object
27 28 29 |
# File 'lib/weather_gov/identifier.rb', line 27 def id uri.sub(/^#{self.class.base_uri}/, "") end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/weather_gov/identifier.rb', line 23 def to_s id end |