Class: Iss

Inherits:
Object
  • Object
show all
Defined in:
lib/where_is_ISS.rb

Class Method Summary collapse

Class Method Details

.coordinates?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/where_is_ISS.rb', line 20

def self.coordinates?
  p @coord = [@lat, @long]   # return array of lat, long
end

.info?Boolean

all the information is being retrieved from @data variable in track function

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/where_is_ISS.rb', line 24

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?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
39
# File 'lib/where_is_ISS.rb', line 31

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

.trackObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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 iss['timezone_id']   # put out the location
  else
    puts("Currently ISS is over Water bodies(Coordinates works only on land)")
  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