Sha256: 97dcb251c3dc5c922be3f36e0310d68556d0aae772ac94ba1c478392885918a8

Contents?: true

Size: 674 Bytes

Versions: 2

Compression:

Stored size: 674 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

2 entries across 2 versions & 1 rubygems

Version Path
MonkeyEngine-2.0.2 lib/MonkeyAction/monkey_timed_action.rb
MonkeyEngine-2.0.1 lib/MonkeyAction/monkey_timed_action.rb