Class: FCC::Station::Result
- Inherits:
-
Object
- Object
- FCC::Station::Result
- Defined in:
- lib/fcc/station.rb
Constant Summary collapse
- EXTENDED_ATTRIBUTES =
these take a long time to query
i[signal_strength latitude longitude coordinates station_class file_number effective_radiated_power haat_horizontal haat_vertical]
- BASIC_ATTRIBUTES =
i[id call_sign status rf_channel license_expiration_date facility_type frequency]
Instance Method Summary collapse
- #community ⇒ Object
- #contact ⇒ Object
- #coordinates ⇒ Object
- #coordinates_url ⇒ Object
- #data ⇒ Object
- #extended_data ⇒ Object
- #extended_data_url ⇒ Object
-
#initialize(service, call_sign, options = {}) ⇒ Result
constructor
A new instance of Result.
- #owner ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(service, call_sign, options = {}) ⇒ Result
Returns a new instance of Result.
52 53 54 55 56 57 58 |
# File 'lib/fcc/station.rb', line 52 def initialize(service, call_sign, = {}) @call_sign = call_sign.upcase @service = service = data end |
Instance Method Details
#community ⇒ Object
77 78 79 |
# File 'lib/fcc/station.rb', line 77 def community @community ||= Community.new(city: data.communityCity, state: data.communityState) end |
#contact ⇒ Object
81 82 83 84 |
# File 'lib/fcc/station.rb', line 81 def contact contact = data.mainStudioContact @contact ||= Contact.new(name: contact['contactName'], title: contact['contactTitle'], address: contact['contactAddress1'], address2: contact['contactAddress2'], city: contact['contactCity'], state: contact['contactState'], zip_code: contact['contactZip'], phone: contact['contactPhone'], fax: contact['contactFax'], email: contact['contactEmail'], website: contact['contactWebsite']) end |
#coordinates ⇒ Object
86 87 88 |
# File 'lib/fcc/station.rb', line 86 def coordinates [latitude.to_f, longitude.to_f].to_json end |
#coordinates_url ⇒ Object
90 91 92 |
# File 'lib/fcc/station.rb', line 90 def coordinates_url "https://www.google.com/maps/search/#{coordinates[0]},#{coordinates[1]}" end |
#data ⇒ Object
102 103 104 |
# File 'lib/fcc/station.rb', line 102 def data @data ||= ResultDelegate.new(Info.new(@service).find(@call_sign)) end |
#extended_data ⇒ Object
98 99 100 |
# File 'lib/fcc/station.rb', line 98 def extended_data @extended_data ||= ResultDelegate.new(ExtendedInfo.new(@service).find(@call_sign)) end |
#extended_data_url ⇒ Object
94 95 96 |
# File 'lib/fcc/station.rb', line 94 def extended_data_url "https://transition.fcc.gov/fcc-bin/#{@service.to_s.downcase}q?list=4&facid=#{id}" end |
#owner ⇒ Object
73 74 75 |
# File 'lib/fcc/station.rb', line 73 def owner @owner ||= Contact.new(name: data.partyName, address: data.partyAddress1, address2: data.partyAddress2, city: data.partyCity, state: data.partyState, zip_code: data.partyZip1, phone: data.partyPhone) end |
#to_json ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fcc/station.rb', line 60 def to_json {}.tap do |hash| [EXTENDED_ATTRIBUTES | BASIC_ATTRIBUTES | i[contact owner community]].flatten.each do |attr| result = send(attr.to_sym) if result.respond_to?(:to_h) hash[attr] = result.to_h else hash[attr] = result.to_s end end end end |