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.
10 11 12 |
# File 'lib/fcc/station/index.rb', line 10 def initialize(service) @service = service end |
Instance Attribute Details
#service ⇒ Object
Returns the value of attribute service.
8 9 10 |
# File 'lib/fcc/station/index.rb', line 8 def service @service end |
Instance Method Details
#call_sign_to_id(call_sign) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fcc/station/index.rb', line 14 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
26 27 28 |
# File 'lib/fcc/station/index.rb', line 26 def inspect "<Station::Index @results=[#{results.size}]>" end |
#results ⇒ Object
30 31 32 33 34 35 |
# File 'lib/fcc/station/index.rb', line 30 def results @results ||= begin response = self.class.get("/api/service/#{service.to_s.downcase}/facility/getall.json") response.parsed_response['results']['facilityList'] end end |