Sha256: e0e52d41b32293be4b8aabce92e360a016e1f2707331e9ffd9ff8210c13929a8

Contents?: true

Size: 686 Bytes

Versions: 1

Compression:

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

    self
  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

1 entries across 1 versions & 1 rubygems

Version Path
MonkeyEngine-2.0.0 lib/MonkeyAction/monkey_timed_action.rb