Sha256: b450746bee78b55fdf23f74e73e7518a8ad88c200a51a9fda289f880677c8d9e
Contents?: true
Size: 428 Bytes
Versions: 2
Compression:
Stored size: 428 Bytes
Contents
module SpaceshipMissionSimulator AVAILABLE_PLANETS = { earth: 9.807, moon: 1.62, mars: 3.711 }.freeze Planet = Struct.new(:gravity, :key, :name, keyword_init: true) do def self.known_gravity?(gravity) AVAILABLE_PLANETS.value? gravity end def fill_up_data tap do |planet| planet.key = AVAILABLE_PLANETS.key gravity planet.name = key.to_s.capitalize end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spaceship_mission_simulator-0.2.0 | lib/spaceship_mission_simulator/planet.rb |
spaceship_mission_simulator-0.1.0 | lib/spaceship_mission_simulator/planet.rb |