Class: AngryMob::Mob
Instance Attribute Summary collapse
-
#act_scheduler ⇒ Object
readonly
Returns the value of attribute act_scheduler.
-
#consolidate_node ⇒ Object
node defaults.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#node_defaults ⇒ Object
node defaults.
-
#notifier ⇒ Object
readonly
Returns the value of attribute notifier.
-
#setup_node ⇒ Object
node defaults.
-
#target_mother ⇒ Object
readonly
Returns the value of attribute target_mother.
Class Method Summary collapse
-
.ui ⇒ Object
delegate to the curren ui.
- .ui! ⇒ Object
- .ui=(ui) ⇒ Object
Instance Method Summary collapse
-
#acts ⇒ Object
acts.
-
#initialize ⇒ Mob
constructor
A new instance of Mob.
-
#riot!(nodename, attributes) ⇒ Object
main entry point the the whole system.
-
#run! ⇒ Object
runs acts and then delayed targets.
-
#setup! ⇒ Object
bind selected targets to the node.
- #ui ⇒ Object
Constructor Details
#initialize ⇒ Mob
Returns a new instance of Mob.
6 7 8 9 |
# File 'lib/angry_mob/mob.rb', line 6 def initialize @target_mother = Target::Mother.new(self) @act_scheduler = Act::Scheduler.new(self) end |
Instance Attribute Details
#act_scheduler ⇒ Object (readonly)
Returns the value of attribute act_scheduler.
4 5 6 |
# File 'lib/angry_mob/mob.rb', line 4 def act_scheduler @act_scheduler end |
#consolidate_node ⇒ Object
node defaults
69 70 71 |
# File 'lib/angry_mob/mob.rb', line 69 def consolidate_node @consolidate_node end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/angry_mob/mob.rb', line 4 def node @node end |
#node_defaults ⇒ Object
node defaults
69 70 71 |
# File 'lib/angry_mob/mob.rb', line 69 def node_defaults @node_defaults end |
#notifier ⇒ Object (readonly)
Returns the value of attribute notifier.
4 5 6 |
# File 'lib/angry_mob/mob.rb', line 4 def notifier @notifier end |
#setup_node ⇒ Object
node defaults
69 70 71 |
# File 'lib/angry_mob/mob.rb', line 69 def setup_node @setup_node end |
#target_mother ⇒ Object (readonly)
Returns the value of attribute target_mother.
4 5 6 |
# File 'lib/angry_mob/mob.rb', line 4 def target_mother @target_mother end |
Class Method Details
.ui ⇒ Object
delegate to the curren ui
12 13 14 |
# File 'lib/angry_mob/mob.rb', line 12 def self.ui (@ui ||= ui!).current end |
.ui! ⇒ Object
15 16 17 |
# File 'lib/angry_mob/mob.rb', line 15 def self.ui! @ui = UI.new end |
.ui=(ui) ⇒ Object
18 19 20 |
# File 'lib/angry_mob/mob.rb', line 18 def self.ui=(ui) @ui = ui end |
Instance Method Details
#acts ⇒ Object
acts
72 73 74 |
# File 'lib/angry_mob/mob.rb', line 72 def acts @acts ||= Dictionary.new end |
#riot!(nodename, attributes) ⇒ Object
main entry point the the whole system
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/angry_mob/mob.rb', line 26 def riot!(nodename, attributes) start = Time.now ui.info "An AngryMob is rioting on #{nodename}." @node = Node.new(nodename, attributes) @act_scheduler.node = @node @notifier = Notifier.new(self) setup! run! ui.info "beaten in #{Time.now-start}s" ui.info "#{nodename} has been beaten by an AngryMob. Have a nice day!" @target_mother.clear_instances! @act_scheduler.reset! end |
#run! ⇒ Object
runs acts and then delayed targets
61 62 63 |
# File 'lib/angry_mob/mob.rb', line 61 def run! act_scheduler.run! end |
#setup! ⇒ Object
bind selected targets to the node
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/angry_mob/mob.rb', line 45 def setup! ui.task "setting up node" defaults = AngryHash.new setup_node[node,defaults] if setup_node node_defaults[node,defaults] if node_defaults consolidate_node[node,defaults] if consolidate_node node.setup_finished! ui.good "setup complete" self end |
#ui ⇒ Object
21 22 23 |
# File 'lib/angry_mob/mob.rb', line 21 def ui self.class.ui end |