radiofreq 0.1.0 → 0.2.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/.gitignore +3 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +7 -2
- data/lib/radiofreq.rb +1 -0
- data/lib/radiofreq/freq.rb +26 -10
- data/lib/radiofreq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87a87f726f93d68683fe0ba29400bfbc886ad187127ddf7cbc31ab6233dadd79
|
|
4
|
+
data.tar.gz: bdcca77c1e54fadd8e2ae94590b5cfec5b25648e34a46086a3eb1f81090d2bce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27b9c1da36bf3470cd002f63efdb0905beabc1656c6b296514063dd3c16e7666d38359df8f2c38a65a4cbf7db480090a0da4ac116964c12cbc4aad0a28306be4
|
|
7
|
+
data.tar.gz: 809f6af87fe498fa90dce208b78072d5c7c901135f62a78e0f04f01b1d5c6cb0062caddae80a0a0304e551bc4812c48a933322037c60b85b9425602ba41046da
|
data/.gitignore
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
|
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
|
55
55
|
## Enforcement
|
|
56
56
|
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at ryan
|
|
58
|
+
reported by contacting the project team at ryan DOT m DOT sherer AT gmail DOT com. All
|
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# radiofreq
|
|
2
2
|
|
|
3
3
|
A gem that you can use to convert a frequency to the corresponding frequency name.
|
|
4
4
|
|
|
@@ -20,7 +20,12 @@ Or install it yourself as:
|
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
```
|
|
24
|
+
irb(main):001:0> require "radiofreq"
|
|
25
|
+
=> true
|
|
26
|
+
irb(main):002:0> Radiofreq::Freq.portray(446.000, 'MHz')
|
|
27
|
+
=> "Ultra High Frequency (UHF)"
|
|
28
|
+
```
|
|
24
29
|
|
|
25
30
|
## Development
|
|
26
31
|
|
data/lib/radiofreq.rb
CHANGED
data/lib/radiofreq/freq.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
module Radiofreq
|
|
2
|
+
# Convert given frequency to frequency descriptive unit
|
|
3
|
+
# Example: 446.000MHz would return: Ultra High Frequency (UHF)
|
|
2
4
|
class Freq
|
|
3
|
-
def self.
|
|
4
|
-
|
|
5
|
+
def self.frequencies
|
|
6
|
+
{
|
|
5
7
|
-Float::INFINITY..3 => {
|
|
6
8
|
'Hz' => 'Tremendously Low Frequency (TLF)'
|
|
7
9
|
},
|
|
@@ -24,16 +26,30 @@ module Radiofreq
|
|
|
24
26
|
'GHz' => 'Tremendously High Frequency'
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
end
|
|
30
|
+
def self.portray(freq, unit)
|
|
31
|
+
frequency_range = get_frequency_range(freq)
|
|
32
|
+
if frequency_range.empty?
|
|
29
33
|
return "Invalid frequency provided: #{freq}"
|
|
30
34
|
else
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
return get_descriptive_unit(frequency_range,unit)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
def self.get_frequency_range(freq)
|
|
39
|
+
filtered_frequencies = frequencies.select{|freq_range,_|freq_range === freq}
|
|
40
|
+
if filtered_frequencies
|
|
41
|
+
return filtered_frequencies
|
|
42
|
+
else
|
|
43
|
+
return "Invalid frequency provided: #{freq}"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
def self.get_descriptive_unit(range,unit)
|
|
47
|
+
range.each do|key,value|
|
|
48
|
+
found_unit = value[unit]
|
|
49
|
+
if found_unit
|
|
50
|
+
return found_unit
|
|
51
|
+
else
|
|
52
|
+
return "Invalid frequency unit: #{unit}"
|
|
37
53
|
end
|
|
38
54
|
end
|
|
39
55
|
end
|
data/lib/radiofreq/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: radiofreq
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Sherer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-07-
|
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|