Class: FCC::Station::Index
- Inherits:
-
Object
- Object
- FCC::Station::Index
- Includes:
- HTTParty
- Defined in:
- lib/fcc/station/index.rb
Instance Attribute Summary collapse
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
- #call_sign_to_id(call_sign) ⇒ Object
-
#initialize(service) ⇒ Index
constructor
A new instance of Index.
- #inspect ⇒ Object
- #results ⇒ Object
Constructor Details
#initialize(service) ⇒ Index
Returns a new instance of Index.
11 12 13 |
# File 'lib/fcc/station/index.rb', line 11 def initialize(service) @service = service end |
Instance Attribute Details
#service ⇒ Object
Returns the value of attribute service.
9 10 11 |
# File 'lib/fcc/station/index.rb', line 9 def service @service end |
Instance Method Details
#call_sign_to_id(call_sign) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fcc/station/index.rb', line 15 def call_sign_to_id(call_sign) found = results.detect do |hash| hash['callSign'] == call_sign.upcase end found ||= results.detect do |hash| hash['callSign'] == "#{call_sign.upcase}-#{service.to_s.upcase}" end found['id'] if found end |
#inspect ⇒ Object
27 28 29 |
# File 'lib/fcc/station/index.rb', line 27 def inspect "<Station::Index @results=[#{results.size}]>" end |
#results ⇒ Object
31 32 33 34 35 36 |
# File 'lib/fcc/station/index.rb', line 31 def results @results ||= begin response = self.class.get("/api/service/#{service.to_s.downcase}/facility/getall.json") response.parsed_response['results']['facilityList'] end end |