Module: SpaceshipMissionSimulator
- Defined in:
- lib/spaceship_mission_simulator.rb,
lib/spaceship_mission_simulator/path.rb,
lib/spaceship_mission_simulator/event.rb,
lib/spaceship_mission_simulator/planet.rb,
lib/spaceship_mission_simulator/version.rb,
lib/spaceship_mission_simulator/simulation_result.rb,
lib/spaceship_mission_simulator/interactors/simulate.rb,
lib/spaceship_mission_simulator/interactors/simulate_event.rb,
lib/spaceship_mission_simulator/interactors/identify_planet.rb,
lib/spaceship_mission_simulator/interactors/validate_raw_path.rb,
lib/spaceship_mission_simulator/interactors/validate_event_data.rb,
lib/spaceship_mission_simulator/interactors/validate_event_state.rb,
lib/spaceship_mission_simulator/interactors/validate_start_event.rb,
lib/spaceship_mission_simulator/interactors/validate_finish_event.rb,
lib/spaceship_mission_simulator/interactors/validate_initial_weight.rb,
lib/spaceship_mission_simulator/interactors/validate_path_consistency.rb
Defined Under Namespace
Classes: Event, IdentifyPlanet, Path, Planet, Simulate, SimulateEvent, SimulationResult, ValidateEventData, ValidateEventState, ValidateFinishEvent, ValidateInitialWeight, ValidatePathConsistency, ValidateRawPath, ValidateStartEvent
Constant Summary
collapse
- EVENT_STATES =
%i[land launch].freeze
- EVENT_ATTRS =
%i[state planet reserved_fuel_weight fuel_weight].freeze
- AVAILABLE_PLANETS =
{
earth: 9.807, moon: 1.62, mars: 3.711
}.freeze
- VERSION =
'0.2.0'.freeze
- RESULT_ATTRS =
%i[initial_weight total_fuel_weight path].freeze
Instance Method Summary
collapse
Instance Method Details
#print_spaceship_mission_result(*args) ⇒ Object
9
10
11
12
13
|
# File 'lib/spaceship_mission_simulator.rb', line 9
def print_spaceship_mission_result(*args)
simulate_spaceship_mission!(*args).result.awesome_print
rescue Interactor::Failure => e
p "Error: #{e.context.message}"
end
|
#simulate_spaceship_mission!(initial_weight, raw_path) ⇒ Object
4
5
6
7
|
# File 'lib/spaceship_mission_simulator.rb', line 4
def simulate_spaceship_mission!(initial_weight, raw_path)
Simulate.call! initial_weight: initial_weight,
raw_path: raw_path
end
|