Class: SpaceshipMissionSimulator::Planet

Inherits:
Struct
  • Object
show all
Defined in:
lib/spaceship_mission_simulator/planet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gravityObject

Returns the value of attribute gravity

Returns:

  • (Object)

    the current value of gravity



6
7
8
# File 'lib/spaceship_mission_simulator/planet.rb', line 6

def gravity
  @gravity
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



6
7
8
# File 'lib/spaceship_mission_simulator/planet.rb', line 6

def key
  @key
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/spaceship_mission_simulator/planet.rb', line 6

def name
  @name
end

Class Method Details

.known_gravity?(gravity) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/spaceship_mission_simulator/planet.rb', line 7

def self.known_gravity?(gravity)
  AVAILABLE_PLANETS.value? gravity
end

Instance Method Details

#fill_up_dataObject



11
12
13
14
15
16
# File 'lib/spaceship_mission_simulator/planet.rb', line 11

def fill_up_data
  tap do |planet|
    planet.key = AVAILABLE_PLANETS.key gravity
    planet.name = key.to_s.capitalize
  end
end