class Rootage::ScenarioDefinition
ScenarioDefinition
is an information table for Scenario
class.
Public Class Methods
new(table=Hash.new)
click to toggle source
Create a new information table.
# File lib/rootage/scenario.rb, line 5 def initialize(table=Hash.new) @table = table self[:name] ||= "anonymous" end
Public Instance Methods
[]=(key, val)
click to toggle source
# File lib/rootage/scenario.rb, line 54 def []=(key, val) define(key, val) end
block_of(key)
click to toggle source
Return the item block of the key.
@param key [Object]
the key
@return [Object]
the block
# File lib/rootage/scenario.rb, line 48 def block_of(key) if @table.has_key?(key) @table[key][:block] end end
clone()
click to toggle source
# File lib/rootage/scenario.rb, line 66 def clone self.class.new(@table.clone) end
define(key, val=nil, &block)
click to toggle source
Define a scenario information that associates key and value.
@param key [Symbol]
key name
@param val [Object]
item's value
@param args_block [Proc]
value's arguments
@return [void]
# File lib/rootage/scenario.rb, line 22 def define(key, val=nil, &block) if val.nil? and not(block_given?) raise ArgumentError.new("Cannot define %{key} with no data." % {key: key}) end @table[key] = {value: val, block: block} end
desc()
click to toggle source
# File lib/rootage/scenario.rb, line 62 def desc self[:desc] end
scenario_name()
click to toggle source
# File lib/rootage/scenario.rb, line 58 def scenario_name self[:name] end
value_of(key)
click to toggle source
Return the item value of the key.
@param key [Object]
the key
@return [Object]
the value
# File lib/rootage/scenario.rb, line 35 def value_of(key) if @table.has_key?(key) @table[key][:value] end end
Also aliased as: []