Sha256: ceb8a0d16dd4ad2e5095527c81b154e785d05f69d292b7953b91ea80e86f531d

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

require 'awesome_print'

module SpaceshipMissionSimulator
  RESULT_ATTRS = %i[initial_weight total_fuel_weight path].freeze

  SimulationResult = Struct.new(*RESULT_ATTRS, keyword_init: true) do
    def awesome_print
      with_suppressed_warnings do
        ap ["path: #{path.print}",
            "weight of equipment: #{initial_weight} kg",
            "weight of fuel: #{total_fuel_weight} kg",
            "arguments: #{initial_weight}, #{path.raw_data}"]
      end
    end

    private

    def with_suppressed_warnings
      original_verbose = $VERBOSE
      $VERBOSE = nil
      yield
      $VERBOSE = original_verbose
    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/simulation_result.rb
spaceship_mission_simulator-0.1.0 lib/spaceship_mission_simulator/simulation_result.rb