Class: Iss
- Inherits:
-
Object
- Object
- Iss
- Defined in:
- lib/where_is_ISS.rb
Class Method Summary collapse
- .coordinates ⇒ Object
-
.info ⇒ Object
all the information is being retrieved from @data variable in track function.
- .members ⇒ Object
- .track ⇒ Object
Class Method Details
.coordinates ⇒ Object
22 23 24 |
# File 'lib/where_is_ISS.rb', line 22 def self.coordinates p @coord = [@lat, @long] # return array of lat, long end |
.info ⇒ Object
all the information is being retrieved from @data variable in track function
26 27 28 29 30 |
# File 'lib/where_is_ISS.rb', line 26 def self.info # all the information is being retrieved from @data variable in track function p @info = [@data['name'],@data['id'],@data['latitude'],@data['longitude'],@data['altitude'],@data['velocity'], @data['visibility'],@data['timestamp'],@data['solar_lat'],@data['solar_lon'],@data['units']] # return array of information end |
.members ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/where_is_ISS.rb', line 33 def self.members @data_1 = JSON[open('http://api.open-notify.org/astros.json').read] @members = [] puts "#{@data_1['number']} people on ISS" @data_1['people'].each do |d| @members << d['name'] end p @members # return array of members end |
.track ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/where_is_ISS.rb', line 8 def self.track @data = JSON[open('https://api.wheretheiss.at/v1/satellites/25544').read] # parsing the satellite data to JSON format @lat = @data['latitude'] # getting latitude from parsed response @long = @data['longitude'] # getting longtitude from parsed response response = Net::HTTP.get_response(URI.parse("https://api.wheretheiss.at/v1/coordinates/#{@lat},#{@long}")) # Checking for 200 OK response from Server if (response.code).to_i == 200 @iss = JSON[open("https://api.wheretheiss.at/v1/coordinates/#{@lat},#{@long}").read] # Print out data if status = 200 OK p @position = @iss['timezone_id'] # put out the location return @position else p @default = "Currently ISS is over Water bodies(Coordinates works only on land)" return @default end def self.coordinates p @coord = [@lat, @long] # return array of lat, long end def self.info # all the information is being retrieved from @data variable in track function p @info = [@data['name'],@data['id'],@data['latitude'],@data['longitude'],@data['altitude'],@data['velocity'], @data['visibility'],@data['timestamp'],@data['solar_lat'],@data['solar_lon'],@data['units']] # return array of information end end |