WSWSANE 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/WSWSANE.rb +62 -0
  3. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b21144c7ceadf658158ef04b1b438752d960dcea9b2bb3799e49bbac7c813882
4
- data.tar.gz: a4aa032dabb191b691a0c5ddeaf5a1369b5143604249640568d8921098c11ffd
3
+ metadata.gz: 3e41f95af1f8f11132db6989cc9198477a11f37c96a02cd78f60e6c54c730416
4
+ data.tar.gz: abf7f5b17cb4889e3516d2c5334e2097c5d76a60abcc61c715bdef40ebcfc68e
5
5
  SHA512:
6
- metadata.gz: 4a816efb694ca9c124949ad7f77df89a1672b775acd356bfdcbbd6720c5214ce4efea2f5635b681ac3656fd1910579640ae0469c4f97757b1bba5cf9385199ae
7
- data.tar.gz: 83ae4b1b1c3d4cbc63d3849519cc9b8d95f254ae3bf2feb79fcd4d31091f58a60bf7949353cb303af5d7325c490acb98d127e33c8b3abec08b0cb51188a3d503
6
+ metadata.gz: 9141788b9e0cc3da0ba0badaf7902c73f7dcacb1e3e9f5ed75c639ea18c3fbd736b35a2c7c292bc62328013782f537bff1cb28f1e08b27a601913a3fbba1476c
7
+ data.tar.gz: e4af29d57ea2a0e3b9364d0f5096db571137f62735f5070fede748e5b678d17ba289726368deff0a186b0b54197f57fb77ca903454c7e756d0bf466d58ab3201
@@ -1,5 +1,7 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
+ ##
4
+ # This class is a static class from which all functions are called
3
5
  class WSWSANE
4
6
  @@reference={:cis=>[
5
7
  ["The Malevolence", 4845],
@@ -62,10 +64,58 @@ class WSWSANE
62
64
  ["A-wing Starfighter", 9.6]
63
65
  ]
64
66
  }
67
+ ##
68
+ # Returns the NASA NEO API response for the current day (as given by Time.now), but each object has an additional field for the closest sized ship.
69
+ # @param apikey [String] The Api Key given to you by api.nasa.gov.
70
+ # @param factions [Array] An optional array of "factions" that will be used to compare objects. By default, this will compare all NEOs with all ships.
71
+ # @return [Hash]
72
+ #
73
+ # Example Usage:
74
+ #
75
+ # If you wanted to compare all objects that have their closest approach to earth today to ships from the original trilogy, you could use:
76
+ # WSWSANE.getToday(apikey,["rebel_alliance","empire"])
77
+ #
78
+ # The return value is very similar to the data provided by the NASA API (it is also a JSON object).
79
+ #
80
+ # To get a list of all the comparisons, you could do:
81
+ # WSWSANE.getToday(apikey)["near_earth_objects"].each do |date,objects|
82
+ # objects.each do |neo|
83
+ # puts neo["star_wars_ship"]
84
+ # end
85
+ # end
86
+ #
87
+ # If no suitable comparison for an object can be found, then the classified ship will be "None".
88
+ #
89
+ # If the api key is incorrect, or the api request otherwise fails, then an error will be raised.
65
90
  def self.getToday(apikey,factions=["cis","republic","empire","rebel_alliance","first_order","resistance"])
66
91
  date=Time.new.strftime("%Y-%m-%d")
67
92
  return self.get(apikey,date,date,factions)
68
93
  end
94
+ ##
95
+ # Returns the NASA NEO API response for the range of dates provided, but each object has an additional field for the closest sized ship.
96
+ # @param apikey [String] The Api Key given to you by api.nasa.gov
97
+ # @param startDate [String] The start date in the form "YYYY-MM-DD"
98
+ # @param endDate [String] The end date in the form "YYYY-MM-DD"
99
+ # The date parameters are inclusive, and together determine the range of days for closest approach of the NEOs that the api returns.
100
+ # @param factions [Array] An optional array of "factions" that will be used to compare objects. By default, this will compare all NEOs with all ships.
101
+ #
102
+ # Example Usage:
103
+ #
104
+ # If you wanted to compare all objects that have their closest approach to earth in the first week of 2020 to ships from the prequel trilogy, you could use:
105
+ # WSWSANE.get(apikey,"2020-01-01","2020-01-07",["cis","republic"])
106
+ #
107
+ # The return value is very similar to the data provided by the NASA API (it is also a JSON object).
108
+ #
109
+ # To get a list of all the comparisons, you could do:
110
+ # WSWSANE.get(apikey,"2020-01-01","2020-01-07")["near_earth_objects"].each do |date,objects|
111
+ # objects.each do |neo|
112
+ # puts neo["star_wars_ship"]
113
+ # end
114
+ # end
115
+ #
116
+ # If no suitable comparison for an object can be found, then the classified ship will be "None".
117
+ #
118
+ # If the api key is incorrect, or the api request otherwise fails, then an error will be raised.
69
119
  def self.get(apikey,startDate,endDate,factions=["cis","republic","empire","rebel_alliance","first_order","resistance"])
70
120
  uri=URI("https://api.nasa.gov/neo/rest/v1/feed")
71
121
  params={:start_date=>startDate,
@@ -86,6 +136,18 @@ class WSWSANE
86
136
  raise response.body
87
137
  end
88
138
  end
139
+ ##
140
+ # Classifies an object based on the range of sizes it could be.
141
+ # @param minSize [Integer] The minimum size of the object in meters
142
+ # @param maxSize [Integer] The maximum size of the object in meters
143
+ # @param factions [Array] An optional array of "factions" that will be used to compare objects. By default, this will compare all NEOs with all ships.
144
+ #
145
+ # Example Usage:
146
+ #
147
+ # If you wanted to compare an object between 5 and 10 meters big to ships from the sequel trilogy, you could use:
148
+ # WSWSANE.classify(5,10,["first_order","resistance"])
149
+ #
150
+ # If no suitable comparison for an object can be found, then the classified ship will be "None".
89
151
  def self.classify(minSize,maxSize,factions=["cis","republic","empire","rebel_alliance","first_order","resistance"])
90
152
  factions.map!(&:downcase)
91
153
  possibleShips=[]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: WSWSANE
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcy Brook
@@ -10,20 +10,22 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A simple tool that uses the NASA NEOWS API to find nearby space objects
14
- and determine which Star Wars ship they are most likely to be.
13
+ description: What Star Wars Ships are Near Earth? This simple tool uses the NASA NEOWS
14
+ API to find nearby space objects and determine which Star Wars ship they are most
15
+ likely to be.
15
16
  email:
16
17
  executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - lib/WSWSANE.rb
21
- homepage:
22
+ homepage: https://rubygems.org/gems/WSWSANE
22
23
  licenses:
23
24
  - Unlicense
24
25
  metadata: {}
25
26
  post_install_message:
26
- rdoc_options: []
27
+ rdoc_options:
28
+ - yard
27
29
  require_paths:
28
30
  - lib
29
31
  required_ruby_version: !ruby/object:Gem::Requirement