class FCC::Station::Result

Constants

BASIC_ATTRIBUTES
EXTENDED_ATTRIBUTES

Public Class Methods

new(service, call_sign, options = {}) click to toggle source
# File lib/fcc/station/result.rb, line 9
def initialize(service, call_sign, options = {})
  @call_sign = call_sign.upcase
  @service = service
  @options = options

  data

  self
end

Public Instance Methods

all_records() click to toggle source
# File lib/fcc/station/result.rb, line 69
def all_records
  [public_records, transition_records, related_translators].flatten.compact.filter { |f| f.has_data? }
end
call_signs_match?(ours, theirs) click to toggle source
# File lib/fcc/station/result.rb, line 133
def call_signs_match?(ours, theirs)
  theirs.to_s.upcase.to_s == ours.to_s.upcase.to_s || theirs.to_s.upcase =~ Regexp.new("^#{ours.to_s.upcase}[-—–][A-Z0-9]+$")
end
coordinates_url() click to toggle source
# File lib/fcc/station/result.rb, line 39
def coordinates_url
  "https://www.google.com/maps/search/#{latitude},#{longitude}" if latitude.present? && longitude.present?
end
data() click to toggle source
# File lib/fcc/station/result.rb, line 51
def data
  @data ||= RecordDelegate.new(Info.new(@service).find(@call_sign))
end
Also aliased as: public_data
details_available?() click to toggle source
# File lib/fcc/station/result.rb, line 19
def details_available?
  exists? && data.latitude.present?
end
enterprise_data_url() click to toggle source
# File lib/fcc/station/result.rb, line 47
def enterprise_data_url
  "https://enterpriseefiling.fcc.gov/dataentry/public/tv/publicFacilityDetails.html?facilityId=#{id}"
end
exists?() click to toggle source
# File lib/fcc/station/result.rb, line 27
def exists?
  grouped_records.any?
end
extended_data_url() click to toggle source
# File lib/fcc/station/result.rb, line 43
def extended_data_url
  "https://transition.fcc.gov/fcc-bin/#{@service.to_s.downcase}q?list=4&facid=#{id}"
end
grouped_records() click to toggle source
# File lib/fcc/station/result.rb, line 56
def grouped_records
  grouped = all_records.group_by do |record|
    [record.id, record.call_sign, record.band, record.frequency].compact.join('/')
  end

  [].tap do |res|
    grouped.each do |_key, values|
      res << RecordGroup.new(values)
    end
  end
end
Also aliased as: records
licensed?() click to toggle source
# File lib/fcc/station/result.rb, line 23
def licensed?
  exists? && data.status == 'LICENSED' && data.license_expiration_date && Time.parse(data.license_expiration_date) > Time.now
end
lms_data() click to toggle source
# File lib/fcc/station/result.rb, line 129
def lms_data
  @lms_data ||= LmsData.new
end
print_broadcast_summary() click to toggle source
public_data()
Alias for: data
records()
Alias for: grouped_records
to_json(*_args) click to toggle source
# File lib/fcc/station/result.rb, line 31
def to_json(*_args)
  [].tap do |records|
    grouped_records.each do |rg|
      records << rg.to_json
    end
  end.flatten.compact.uniq
end

Private Instance Methods

method_missing(m, *_args) click to toggle source
# File lib/fcc/station/result.rb, line 161
def method_missing(m, *_args)
  service = if @service == :fm
              fm_record = grouped_records.find { |gr| FCC::FM_FULL_SERVICE == gr.band.upcase }
              fm_low_power = grouped_records.find { |gr| FCC::FM_LOW_POWER == gr.band.upcase }
              fm_booster = grouped_records.find { |gr| FCC::FM_BOOSTER == gr.band.upcase }
              fm_translator = grouped_records.find { |gr| FCC::FM_TRANSLATOR == gr.band.upcase }

              [fm_record, fm_low_power, fm_booster, fm_translator].compact.find { |r| r.send(m.to_sym) }
            else
              grouped_records.find { |r| r.send(m.to_sym) }
            end

  result = service.send(m.to_sym) if service

  result = result.first if result.is_a?(Array) && result.size == 1

  result
end
public_data_info() click to toggle source
# File lib/fcc/station/result.rb, line 153
def public_data_info
  @public_data_info ||= [Info.new(@service).find(@call_sign)]
end
public_records() click to toggle source
# File lib/fcc/station/result.rb, line 139
def public_records
  public_data_info.map { |r| RecordDelegate.new(r) }
end
transition_data_info() click to toggle source
# File lib/fcc/station/result.rb, line 157
def transition_data_info
  @transition_data_info ||= ExtendedInfo.new(@service).find(@call_sign)
end
transition_records() click to toggle source
# File lib/fcc/station/result.rb, line 143
def transition_records
  transition_data_info.map { |r| RecordDelegate.new(r) }
end