Sha256: f51847be0001c5137fbf1238bc02e84e133a455b5b5c65d6a75c3f51336aa059

Contents?: true

Size: 675 Bytes

Versions: 5

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

require_relative 'monkey_action'
require 'MonkeyEngine/exceptions'

# Monkey action:  one that is timed based on an Integer.
class MonkeyTimedAction < MonkeyAction
  attr_accessor :action_time_of_completion

  def initialize(monkey, value, weight)
    super(monkey, value, weight)

    @action_time_of_completion = nil

    validate
  end

  protected

  def validate
    raise MonkeyEngine::Exceptions::NilArgumentException, "Value '#{value}' cannot be nil" \
      if @value.nil?

    raise MonkeyEngine::Exceptions::InvalidArgumentTypeException, "Value '#{value}' is not a valid argument type" \
      unless @value.is_a?(Integer)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
MonkeyEngine-2.0.7 lib/MonkeyAction/monkey_timed_action.rb
MonkeyEngine-2.0.6 lib/MonkeyAction/monkey_timed_action.rb
MonkeyEngine-2.0.5 lib/MonkeyAction/monkey_timed_action.rb
MonkeyEngine-2.0.4 lib/MonkeyAction/monkey_timed_action.rb
MonkeyEngine-2.0.3 lib/MonkeyAction/monkey_timed_action.rb