Class: ProjectSimulator::Controller
- Inherits:
-
Object
- Object
- ProjectSimulator::Controller
- Defined in:
- lib/projectsimulator.rb
Instance Attribute Summary collapse
-
#macros ⇒ Object
readonly
Returns the value of attribute macros.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(mcs, debug: false) ⇒ Controller
constructor
A new instance of Controller.
- #trigger(name, detail = {}) ⇒ Object
Constructor Details
#initialize(mcs, debug: false) ⇒ Controller
Returns a new instance of Controller.
135 136 137 138 139 140 141 142 |
# File 'lib/projectsimulator.rb', line 135 def initialize(mcs, debug: false) @debug = debug @syslog = [] @macros = mcs.macros end |
Instance Attribute Details
#macros ⇒ Object (readonly)
Returns the value of attribute macros.
132 133 134 |
# File 'lib/projectsimulator.rb', line 132 def macros @macros end |
#title ⇒ Object
Returns the value of attribute title.
133 134 135 |
# File 'lib/projectsimulator.rb', line 133 def title @title end |
Instance Method Details
#trigger(name, detail = {}) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/projectsimulator.rb', line 145 def trigger(name, detail={}) macros = @macros.select do |macro| puts 'macro: ' + macro.inspect if @debug valid_trigger = macro.match?(name, detail) puts 'valid_trigger: ' + valid_trigger.inspect if @debug if valid_trigger then @syslog << [Time.now, :trigger, name] @syslog << [Time.now, :macro, macro.title] end valid_trigger end puts 'macros: ' + macros.inspect if @debug macros.flat_map(&:run) end |