class Riot::RunnableBlock

A runnable block is pretty much an anonymous block decorator. It's goal is to accept a block, a description for what the block is intended to be for, and provide a run method expects a {Riot::Situation} instance. Any time a {Riot::Situation} is provided to run, a {Riot::RunnableBlock} promises to evaluate itself against the situation in some way.

Intent is to sub-class {Riot::RunnableBlock} with specific mechanisms for contorting the {Riot::Situation}.

Attributes

definition[R]

The decorated block.

Public Class Methods

new(description, &definition) click to toggle source

Creates a new RunnableBlock.

@param [String] description a description of what this block is for @param [lambda] &definition the block to decorate

# File lib/riot/runnable.rb, line 18
def initialize(description, &definition)
  @description, @definition = description, definition || proc { false }
end

Public Instance Methods

run(situation) click to toggle source

Given a {Riot::Situation}, eval the provided block against it and then return a status tuple.

@param [Riot::Situation] situation An instance of a {Riot::Situation} @return [Array<Symbol[, String]>] array containing at least an evaluation state

# File lib/riot/runnable.rb, line 26
def run(situation)
  raise "Define your own run"
end
to_s() click to toggle source

String representation of this block, which is basically the description.

@return [String]

# File lib/riot/runnable.rb, line 33
def to_s; @description; end