Sha256: 62d9985baa63f6d615b4a77556283941107c572166937281a6755c123ee5bd73

Contents?: true

Size: 915 Bytes

Versions: 38

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module Boxcars
  # Train's action to take.
  class TrainAction
    attr_accessor :boxcar, :boxcar_input, :log

    # record for a train action
    # @param boxcar [String] The boxcar to run.
    # @param log [String] The log of the action.
    # @param boxcar_input [String] The input to the boxcar.
    # @return [Boxcars::TrainAction] The train action.
    def initialize(boxcar:, log:, boxcar_input: nil)
      @boxcar_input = boxcar_input
      @boxcar = boxcar
      @log = log
    end

    # build a train action from a result
    # @param result [Boxcars::Result] The result to build from.
    # @param boxcar [String] The boxcar to run.
    # @param log [String] The log of the action.
    # @return [Boxcars::TrainAction] The train action.
    def self.from_result(result:, boxcar:, log:)
      new(boxcar: boxcar, boxcar_input: result.to_answer, log: log)
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
boxcars-0.3.3 lib/boxcars/train/train_action.rb
boxcars-0.3.2 lib/boxcars/train/train_action.rb
boxcars-0.3.1 lib/boxcars/train/train_action.rb
boxcars-0.2.16 lib/boxcars/train/train_action.rb
boxcars-0.2.15 lib/boxcars/train/train_action.rb
boxcars-0.2.14 lib/boxcars/train/train_action.rb
boxcars-0.2.13 lib/boxcars/train/train_action.rb
boxcars-0.2.12 lib/boxcars/train/train_action.rb
boxcars-0.2.11 lib/boxcars/train/train_action.rb
boxcars-0.2.10 lib/boxcars/train/train_action.rb
boxcars-0.2.9 lib/boxcars/train/train_action.rb
boxcars-0.2.8 lib/boxcars/train/train_action.rb
boxcars-0.2.7 lib/boxcars/train/train_action.rb
boxcars-0.2.5 lib/boxcars/train/train_action.rb
boxcars-0.2.4 lib/boxcars/train/train_action.rb
boxcars-0.2.3 lib/boxcars/train/train_action.rb
boxcars-0.2.2 lib/boxcars/train/train_action.rb
boxcars-0.2.1 lib/boxcars/train/train_action.rb