fcc 1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -14
- data/Gemfile.lock +15 -15
- data/README.md +70 -24
- data/VERSION +1 -1
- data/fcc.gemspec +3 -3
- data/lib/fcc/station/cache.rb +20 -14
- data/lib/fcc/station/extended_info.rb +29 -22
- data/lib/fcc/station/index.rb +1 -1
- data/lib/fcc/station/info.rb +9 -2
- data/lib/fcc/station/lms_data.rb +139 -0
- data/lib/fcc/station/parsers/extended_info.rb +78 -0
- data/lib/fcc/station/parsers/lms_data.rb +13 -0
- data/lib/fcc/station/record_delegate.rb +121 -0
- data/lib/fcc/station/record_group.rb +49 -0
- data/lib/fcc/station/result.rb +178 -0
- data/lib/fcc/station.rb +9 -71
- data/lib/fcc.rb +22 -1
- data/lib/version.rb +1 -1
- metadata +47 -28
- data/lib/fcc/station/extended_info/parser.rb +0 -66
- data/lib/fcc/station/result_delegate.rb +0 -24
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'byebug'
|
3
|
-
|
4
|
-
module FCC
|
5
|
-
module Station
|
6
|
-
class ExtendedInfoParser < HTTParty::Parser
|
7
|
-
def parse
|
8
|
-
results = []
|
9
|
-
body.each_line do |row|
|
10
|
-
attrs = {}
|
11
|
-
attrs[:raw] = row
|
12
|
-
fields = row.split('|').slice(1...-1).collect(&:strip).map { |v| v == '-' ? "" : v }
|
13
|
-
|
14
|
-
attrs[:call_sign] = fields[0]
|
15
|
-
attrs[:frequency] = parse_frequency(fields[1])
|
16
|
-
attrs[:band] = fields[2]
|
17
|
-
attrs[:channel] = fields[3]
|
18
|
-
attrs[:antenna_type] = fields[4] # Directional Antenna (DA) or NonDirectional (ND)
|
19
|
-
attrs[:am_operating_time] = fields[5] if fields[5] && attrs[:band] == "AM" # (Only used for AM)
|
20
|
-
attrs[:station_class] = fields[6]
|
21
|
-
attrs[:region_2_station_class] = fields[7] if fields[7] && attrs[:band] == "AM" # (only used for AM)
|
22
|
-
attrs[:status] = fields[8]
|
23
|
-
attrs[:city] = fields[9]
|
24
|
-
attrs[:state] = fields[10]
|
25
|
-
attrs[:country] = fields[11]
|
26
|
-
attrs[:file_number] = fields[12] #File Number (Application, Construction Permit or License) or
|
27
|
-
attrs[:signal_strength] = parse_signal_strength(fields[13]) # Effective Radiated Power --
|
28
|
-
attrs[:effective_radiated_power] = parse_signal_strength(fields[14]) # Effective Radiated Power -- vertically polarized (maximum)
|
29
|
-
attrs[:haat_horizontal] = fields[15] # Antenna Height Above Average Terrain (HAAT) -- horizontal polarization
|
30
|
-
attrs[:haat_vertical] = fields[16] # Antenna Height Above Average Terrain (HAAT) -- vertical polarization
|
31
|
-
attrs[:fcc_id] = fields[17] # Facility ID Number (unique to each station)
|
32
|
-
attrs[:latitude] = parse_latitude(fields[18], fields[19], fields[20], fields[21])
|
33
|
-
attrs[:longitude] = parse_longitude(fields[22], fields[23], fields[24], fields[25])
|
34
|
-
attrs[:licensed_to] = fields[26] # Licensee or Permittee
|
35
|
-
|
36
|
-
results << attrs
|
37
|
-
end
|
38
|
-
|
39
|
-
results
|
40
|
-
end
|
41
|
-
|
42
|
-
def parse_longitude(direction, degrees, minutes, seconds)
|
43
|
-
decimal_degrees = degrees.to_i + (minutes.to_f / 60) + (seconds.to_f / 3600)
|
44
|
-
|
45
|
-
"#{direction =~ /W/ ? '-' : ''}#{decimal_degrees}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def parse_latitude(direction, degrees, minutes, seconds)
|
49
|
-
decimal_degrees = degrees.to_i + (minutes.to_f / 60) + (seconds.to_f / 3600)
|
50
|
-
|
51
|
-
"#{direction =~ /S/ ? '-' : ''}#{decimal_degrees}"
|
52
|
-
end
|
53
|
-
|
54
|
-
def parse_signal_strength(raw_signal)
|
55
|
-
if raw_signal
|
56
|
-
parsed_signal = raw_signal[/[0-9]+\.?[0-9]?/]
|
57
|
-
"#{parsed_signal.to_f} #{raw_signal.scan(/\w+$/).first}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def parse_frequency(freq)
|
62
|
-
freq.to_f
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'active_support/inflector'
|
2
|
-
require 'byebug'
|
3
|
-
|
4
|
-
module FCC
|
5
|
-
module Station
|
6
|
-
class ResultDelegate
|
7
|
-
def initialize(result)
|
8
|
-
@result = result
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(m, *args, &block)
|
12
|
-
if @result
|
13
|
-
matched_key = @result.keys.detect { |d| m.to_s == d.to_s } || @result.keys.detect { |d| m.to_s == d.underscore.to_s }
|
14
|
-
|
15
|
-
if matched_key
|
16
|
-
@result[matched_key]
|
17
|
-
else
|
18
|
-
super
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|