Class: FCC::Station::ExtendedInfo
- Inherits:
-
Object
- Object
- FCC::Station::ExtendedInfo
- Includes:
- HTTParty
- Defined in:
- lib/fcc/station/extended_info.rb
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
-
#service ⇒ Object
Returns the value of attribute service.
Instance Method Summary collapse
- #all_results ⇒ Object
- #find(id_or_call_sign) ⇒ Object
-
#initialize(service) ⇒ ExtendedInfo
constructor
A new instance of ExtendedInfo.
Constructor Details
#initialize(service) ⇒ ExtendedInfo
Returns a new instance of ExtendedInfo.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fcc/station/extended_info.rb', line 12 def initialize(service) @service = service @options = { follow_redirects: true } @query = { # state: nil, # call: nil, # city: nil, # arn: nil, serv: service.to_s.downcase, vac: 3, # licensed records only # freq: @service.to_sym == :fm ? '87.1' : '530', # fre2: @service.to_sym == :fm ? '107.9' : '1700', # facid: nil, # class: nil, # dkt: nil, # dist: nil, # dlat2: nil, # dlon2: nil, # mlon2: nil, # mlat2: nil, # slat2: nil, # slon2: nil, # NS: "N", # e: 9, # EW: 'W', list: 4, # pipe separated output size: 9 } end |
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
9 10 11 |
# File 'lib/fcc/station/extended_info.rb', line 9 def results @results end |
#service ⇒ Object
Returns the value of attribute service.
9 10 11 |
# File 'lib/fcc/station/extended_info.rb', line 9 def service @service end |
Instance Method Details
#all_results ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/fcc/station/extended_info.rb', line 44 def all_results @all_results ||= begin puts "charging cache for #{service} extended info" response = self.class.get("/#{service.to_s.downcase}q", @options.merge(query: @query)) puts response.request.uri.to_s.gsub('&list=4', '&list=0') response end end |
#find(id_or_call_sign) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fcc/station/extended_info.rb', line 53 def find(id_or_call_sign) if id_or_call_sign =~ /^\d+$/ id = id_or_call_sign else id = FCC::Station.index(@service).call_sign_to_id(id_or_call_sign) end begin FCC::Station.extended_info_cache(@service).find(id) rescue Exception => e response = self.class.get("/#{service.to_s.downcase}q", @options.merge(query: @query.merge(facid: id))) puts response.request.uri.to_s.gsub('&list=4', '&list=0') result = response.first result['source_url'] = response.request.uri.to_s.gsub('&list=4', '&list=0') result end end |