Class: Riot::RunnableBlock
Overview
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 Situation instance. Any time a Situation is provided to run
, a RunnableBlock promises to evaluate itself against the situation in some way.
Intent is to sub-class RunnableBlock with specific mechanisms for contorting the Situation.
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
The decorated block.
Instance Method Summary collapse
-
#initialize(description, &definition) ⇒ RunnableBlock
constructor
Creates a new RunnableBlock.
-
#run(situation) ⇒ Array<Symbol[, String]>
Given a Situation, eval the provided block against it and then return a status tuple.
-
#to_s ⇒ String
String representation of this block, which is basically the description.
Constructor Details
#initialize(description, &definition) ⇒ RunnableBlock
Creates a new RunnableBlock.
18 19 20 |
# File 'lib/riot/runnable.rb', line 18 def initialize(description, &definition) @description, @definition = description, definition || proc { false } end |
Instance Attribute Details
#definition ⇒ Object (readonly)
The decorated block.
12 13 14 |
# File 'lib/riot/runnable.rb', line 12 def definition @definition end |
Instance Method Details
#run(situation) ⇒ Array<Symbol[, String]>
Given a Situation, eval the provided block against it and then return a status tuple.
26 27 28 |
# File 'lib/riot/runnable.rb', line 26 def run(situation) raise "Define your own run" end |
#to_s ⇒ String
String representation of this block, which is basically the description.
33 |
# File 'lib/riot/runnable.rb', line 33 def to_s; @description; end |