state_machine_deuxito 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +8 -0
  4. data/.yardopts +5 -0
  5. data/Appraisals +12 -0
  6. data/CHANGELOG.md +502 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +20 -0
  9. data/README.md +8 -0
  10. data/Rakefile +41 -0
  11. data/TODO.md +2 -0
  12. data/examples/AutoShop_state.png +0 -0
  13. data/examples/Car_state.png +0 -0
  14. data/examples/Gemfile +5 -0
  15. data/examples/Gemfile.lock +14 -0
  16. data/examples/TrafficLight_state.png +0 -0
  17. data/examples/Vehicle_state.png +0 -0
  18. data/examples/auto_shop.rb +13 -0
  19. data/examples/car.rb +21 -0
  20. data/examples/doc/AutoShop.html +2856 -0
  21. data/examples/doc/AutoShop_state.png +0 -0
  22. data/examples/doc/Car.html +919 -0
  23. data/examples/doc/Car_state.png +0 -0
  24. data/examples/doc/TrafficLight.html +2230 -0
  25. data/examples/doc/TrafficLight_state.png +0 -0
  26. data/examples/doc/Vehicle.html +7921 -0
  27. data/examples/doc/Vehicle_state.png +0 -0
  28. data/examples/doc/_index.html +136 -0
  29. data/examples/doc/class_list.html +47 -0
  30. data/examples/doc/css/common.css +1 -0
  31. data/examples/doc/css/full_list.css +55 -0
  32. data/examples/doc/css/style.css +322 -0
  33. data/examples/doc/file_list.html +46 -0
  34. data/examples/doc/frames.html +13 -0
  35. data/examples/doc/index.html +136 -0
  36. data/examples/doc/js/app.js +205 -0
  37. data/examples/doc/js/full_list.js +173 -0
  38. data/examples/doc/js/jquery.js +16 -0
  39. data/examples/doc/method_list.html +734 -0
  40. data/examples/doc/top-level-namespace.html +105 -0
  41. data/examples/merb-rest/controller.rb +51 -0
  42. data/examples/merb-rest/model.rb +28 -0
  43. data/examples/merb-rest/view_edit.html.erb +24 -0
  44. data/examples/merb-rest/view_index.html.erb +23 -0
  45. data/examples/merb-rest/view_new.html.erb +13 -0
  46. data/examples/merb-rest/view_show.html.erb +17 -0
  47. data/examples/rails-rest/controller.rb +43 -0
  48. data/examples/rails-rest/migration.rb +7 -0
  49. data/examples/rails-rest/model.rb +23 -0
  50. data/examples/rails-rest/view__form.html.erb +34 -0
  51. data/examples/rails-rest/view_edit.html.erb +6 -0
  52. data/examples/rails-rest/view_index.html.erb +25 -0
  53. data/examples/rails-rest/view_new.html.erb +5 -0
  54. data/examples/rails-rest/view_show.html.erb +19 -0
  55. data/examples/traffic_light.rb +9 -0
  56. data/examples/vehicle.rb +33 -0
  57. data/gemfiles/4.2.11.1.gemfile +9 -0
  58. data/gemfiles/4.2.11.1.gemfile.lock +57 -0
  59. data/gemfiles/active_model_3.0.0.gemfile +7 -0
  60. data/gemfiles/active_model_3.0.0.gemfile.lock +35 -0
  61. data/gemfiles/active_model_3.0.5.gemfile +7 -0
  62. data/gemfiles/active_model_3.0.5.gemfile.lock +35 -0
  63. data/gemfiles/active_model_3.1.1.gemfile +7 -0
  64. data/gemfiles/active_model_3.1.1.gemfile.lock +36 -0
  65. data/gemfiles/active_model_3.2.1.gemfile +7 -0
  66. data/gemfiles/active_model_3.2.12.gemfile +7 -0
  67. data/gemfiles/active_model_3.2.12.gemfile.lock +36 -0
  68. data/gemfiles/active_model_3.2.13.rc1.gemfile +7 -0
  69. data/gemfiles/active_model_3.2.13.rc1.gemfile.lock +36 -0
  70. data/gemfiles/active_model_4.0.0.gemfile +9 -0
  71. data/gemfiles/active_model_4.0.0.gemfile.lock +78 -0
  72. data/gemfiles/active_record_2.0.0.gemfile +9 -0
  73. data/gemfiles/active_record_2.0.0.gemfile.lock +39 -0
  74. data/gemfiles/active_record_2.0.5.gemfile +9 -0
  75. data/gemfiles/active_record_2.0.5.gemfile.lock +39 -0
  76. data/gemfiles/active_record_2.1.0.gemfile +9 -0
  77. data/gemfiles/active_record_2.1.0.gemfile.lock +39 -0
  78. data/gemfiles/active_record_2.1.2.gemfile +9 -0
  79. data/gemfiles/active_record_2.1.2.gemfile.lock +39 -0
  80. data/gemfiles/active_record_2.2.3.gemfile +9 -0
  81. data/gemfiles/active_record_2.2.3.gemfile.lock +39 -0
  82. data/gemfiles/active_record_2.3.12.gemfile +9 -0
  83. data/gemfiles/active_record_2.3.12.gemfile.lock +39 -0
  84. data/gemfiles/active_record_2.3.5.gemfile +9 -0
  85. data/gemfiles/active_record_2.3.5.gemfile.lock +39 -0
  86. data/gemfiles/active_record_3.0.0.gemfile +9 -0
  87. data/gemfiles/active_record_3.0.0.gemfile.lock +51 -0
  88. data/gemfiles/active_record_3.0.5.gemfile +9 -0
  89. data/gemfiles/active_record_3.0.5.gemfile.lock +50 -0
  90. data/gemfiles/active_record_3.1.1.gemfile +9 -0
  91. data/gemfiles/active_record_3.1.1.gemfile.lock +51 -0
  92. data/gemfiles/active_record_3.2.12.gemfile +9 -0
  93. data/gemfiles/active_record_3.2.12.gemfile.lock +51 -0
  94. data/gemfiles/active_record_3.2.13.rc1.gemfile +9 -0
  95. data/gemfiles/active_record_3.2.13.rc1.gemfile.lock +51 -0
  96. data/gemfiles/active_record_4.0.0.gemfile +11 -0
  97. data/gemfiles/active_record_4.0.0.gemfile.lock +83 -0
  98. data/gemfiles/data_mapper_0.10.2.gemfile +13 -0
  99. data/gemfiles/data_mapper_0.10.2.gemfile.lock +56 -0
  100. data/gemfiles/data_mapper_0.9.11.gemfile +13 -0
  101. data/gemfiles/data_mapper_0.9.11.gemfile.lock +71 -0
  102. data/gemfiles/data_mapper_0.9.4.gemfile +12 -0
  103. data/gemfiles/data_mapper_0.9.4.gemfile.lock +70 -0
  104. data/gemfiles/data_mapper_0.9.7.gemfile +13 -0
  105. data/gemfiles/data_mapper_0.9.7.gemfile.lock +67 -0
  106. data/gemfiles/data_mapper_1.0.0.gemfile +12 -0
  107. data/gemfiles/data_mapper_1.0.0.gemfile.lock +63 -0
  108. data/gemfiles/data_mapper_1.0.1.gemfile +12 -0
  109. data/gemfiles/data_mapper_1.0.1.gemfile.lock +63 -0
  110. data/gemfiles/data_mapper_1.0.2.gemfile +12 -0
  111. data/gemfiles/data_mapper_1.0.2.gemfile.lock +63 -0
  112. data/gemfiles/data_mapper_1.1.0.gemfile +12 -0
  113. data/gemfiles/data_mapper_1.1.0.gemfile.lock +61 -0
  114. data/gemfiles/data_mapper_1.2.0.gemfile +12 -0
  115. data/gemfiles/data_mapper_1.2.0.gemfile.lock +61 -0
  116. data/gemfiles/default.gemfile +5 -0
  117. data/gemfiles/default.gemfile.lock +30 -0
  118. data/gemfiles/graphviz_0.9.17.gemfile +7 -0
  119. data/gemfiles/graphviz_0.9.17.gemfile.lock +29 -0
  120. data/gemfiles/graphviz_0.9.21.gemfile +7 -0
  121. data/gemfiles/graphviz_0.9.21.gemfile.lock +29 -0
  122. data/gemfiles/graphviz_1.0.0.gemfile +7 -0
  123. data/gemfiles/graphviz_1.0.0.gemfile.lock +29 -0
  124. data/gemfiles/graphviz_1.0.3.gemfile +7 -0
  125. data/gemfiles/graphviz_1.0.3.gemfile.lock +29 -0
  126. data/gemfiles/graphviz_1.0.8.gemfile +7 -0
  127. data/gemfiles/graphviz_1.0.8.gemfile.lock +29 -0
  128. data/gemfiles/mongo_mapper_0.10.0.gemfile +8 -0
  129. data/gemfiles/mongo_mapper_0.10.0.gemfile.lock +47 -0
  130. data/gemfiles/mongo_mapper_0.11.2.gemfile +9 -0
  131. data/gemfiles/mongo_mapper_0.11.2.gemfile.lock +48 -0
  132. data/gemfiles/mongo_mapper_0.12.0.gemfile +9 -0
  133. data/gemfiles/mongo_mapper_0.12.0.gemfile.lock +48 -0
  134. data/gemfiles/mongo_mapper_0.5.5.gemfile +8 -0
  135. data/gemfiles/mongo_mapper_0.5.5.gemfile.lock +36 -0
  136. data/gemfiles/mongo_mapper_0.5.8.gemfile +8 -0
  137. data/gemfiles/mongo_mapper_0.5.8.gemfile.lock +36 -0
  138. data/gemfiles/mongo_mapper_0.6.0.gemfile +8 -0
  139. data/gemfiles/mongo_mapper_0.6.0.gemfile.lock +36 -0
  140. data/gemfiles/mongo_mapper_0.6.10.gemfile +8 -0
  141. data/gemfiles/mongo_mapper_0.6.10.gemfile.lock +36 -0
  142. data/gemfiles/mongo_mapper_0.7.0.gemfile +8 -0
  143. data/gemfiles/mongo_mapper_0.7.0.gemfile.lock +36 -0
  144. data/gemfiles/mongo_mapper_0.7.5.gemfile +8 -0
  145. data/gemfiles/mongo_mapper_0.7.5.gemfile.lock +39 -0
  146. data/gemfiles/mongo_mapper_0.8.0.gemfile +10 -0
  147. data/gemfiles/mongo_mapper_0.8.0.gemfile.lock +43 -0
  148. data/gemfiles/mongo_mapper_0.8.3.gemfile +10 -0
  149. data/gemfiles/mongo_mapper_0.8.3.gemfile.lock +43 -0
  150. data/gemfiles/mongo_mapper_0.8.4.gemfile +8 -0
  151. data/gemfiles/mongo_mapper_0.8.4.gemfile.lock +42 -0
  152. data/gemfiles/mongo_mapper_0.8.6.gemfile +8 -0
  153. data/gemfiles/mongo_mapper_0.8.6.gemfile.lock +42 -0
  154. data/gemfiles/mongo_mapper_0.9.0.gemfile +7 -0
  155. data/gemfiles/mongo_mapper_0.9.0.gemfile.lock +45 -0
  156. data/gemfiles/mongoid_2.0.0.gemfile +9 -0
  157. data/gemfiles/mongoid_2.0.0.gemfile.lock +49 -0
  158. data/gemfiles/mongoid_2.1.4.gemfile +9 -0
  159. data/gemfiles/mongoid_2.1.4.gemfile.lock +47 -0
  160. data/gemfiles/mongoid_2.2.4.gemfile +9 -0
  161. data/gemfiles/mongoid_2.2.4.gemfile.lock +47 -0
  162. data/gemfiles/mongoid_2.3.3.gemfile +9 -0
  163. data/gemfiles/mongoid_2.3.3.gemfile.lock +47 -0
  164. data/gemfiles/mongoid_2.4.0.gemfile +9 -0
  165. data/gemfiles/mongoid_2.4.0.gemfile.lock +47 -0
  166. data/gemfiles/mongoid_2.4.10.gemfile +9 -0
  167. data/gemfiles/mongoid_2.4.10.gemfile.lock +47 -0
  168. data/gemfiles/mongoid_2.5.2.gemfile +9 -0
  169. data/gemfiles/mongoid_2.5.2.gemfile.lock +47 -0
  170. data/gemfiles/mongoid_2.6.0.gemfile +9 -0
  171. data/gemfiles/mongoid_2.6.0.gemfile.lock +47 -0
  172. data/gemfiles/mongoid_3.0.0.gemfile +8 -0
  173. data/gemfiles/mongoid_3.0.0.gemfile.lock +45 -0
  174. data/gemfiles/mongoid_3.0.22.gemfile +8 -0
  175. data/gemfiles/mongoid_3.0.22.gemfile.lock +45 -0
  176. data/gemfiles/mongoid_3.1.0.gemfile +8 -0
  177. data/gemfiles/mongoid_3.1.0.gemfile.lock +45 -0
  178. data/gemfiles/sequel_2.11.0.gemfile +9 -0
  179. data/gemfiles/sequel_2.11.0.gemfile.lock +33 -0
  180. data/gemfiles/sequel_2.12.0.gemfile +9 -0
  181. data/gemfiles/sequel_2.12.0.gemfile.lock +33 -0
  182. data/gemfiles/sequel_2.8.0.gemfile +9 -0
  183. data/gemfiles/sequel_2.8.0.gemfile.lock +33 -0
  184. data/gemfiles/sequel_3.0.0.gemfile +9 -0
  185. data/gemfiles/sequel_3.0.0.gemfile.lock +33 -0
  186. data/gemfiles/sequel_3.10.0.gemfile +9 -0
  187. data/gemfiles/sequel_3.10.0.gemfile.lock +33 -0
  188. data/gemfiles/sequel_3.13.0.gemfile +9 -0
  189. data/gemfiles/sequel_3.13.0.gemfile.lock +33 -0
  190. data/gemfiles/sequel_3.14.0.gemfile +9 -0
  191. data/gemfiles/sequel_3.14.0.gemfile.lock +33 -0
  192. data/gemfiles/sequel_3.23.0.gemfile +9 -0
  193. data/gemfiles/sequel_3.23.0.gemfile.lock +33 -0
  194. data/gemfiles/sequel_3.24.0.gemfile +9 -0
  195. data/gemfiles/sequel_3.24.0.gemfile.lock +33 -0
  196. data/gemfiles/sequel_3.29.0.gemfile +9 -0
  197. data/gemfiles/sequel_3.29.0.gemfile.lock +33 -0
  198. data/gemfiles/sequel_3.34.0.gemfile +9 -0
  199. data/gemfiles/sequel_3.34.0.gemfile.lock +33 -0
  200. data/gemfiles/sequel_3.35.0.gemfile +9 -0
  201. data/gemfiles/sequel_3.35.0.gemfile.lock +33 -0
  202. data/gemfiles/sequel_3.4.0.gemfile +9 -0
  203. data/gemfiles/sequel_3.4.0.gemfile.lock +33 -0
  204. data/gemfiles/sequel_3.44.0.gemfile +9 -0
  205. data/gemfiles/sequel_3.44.0.gemfile.lock +33 -0
  206. data/init.rb +1 -0
  207. data/lib/state_machine.rb +8 -0
  208. data/lib/state_machine/assertions.rb +36 -0
  209. data/lib/state_machine/branch.rb +225 -0
  210. data/lib/state_machine/callback.rb +236 -0
  211. data/lib/state_machine/core.rb +12 -0
  212. data/lib/state_machine/core_ext.rb +2 -0
  213. data/lib/state_machine/core_ext/class/state_machine.rb +5 -0
  214. data/lib/state_machine/error.rb +13 -0
  215. data/lib/state_machine/eval_helpers.rb +87 -0
  216. data/lib/state_machine/event.rb +257 -0
  217. data/lib/state_machine/event_collection.rb +141 -0
  218. data/lib/state_machine/extensions.rb +149 -0
  219. data/lib/state_machine/graph.rb +92 -0
  220. data/lib/state_machine/helper_module.rb +17 -0
  221. data/lib/state_machine/initializers.rb +4 -0
  222. data/lib/state_machine/initializers/merb.rb +1 -0
  223. data/lib/state_machine/initializers/rails.rb +25 -0
  224. data/lib/state_machine/integrations.rb +121 -0
  225. data/lib/state_machine/integrations/active_model.rb +585 -0
  226. data/lib/state_machine/integrations/active_model/locale.rb +11 -0
  227. data/lib/state_machine/integrations/active_model/observer.rb +33 -0
  228. data/lib/state_machine/integrations/active_model/observer_update.rb +42 -0
  229. data/lib/state_machine/integrations/active_model/versions.rb +31 -0
  230. data/lib/state_machine/integrations/active_record.rb +552 -0
  231. data/lib/state_machine/integrations/active_record/locale.rb +20 -0
  232. data/lib/state_machine/integrations/active_record/versions.rb +123 -0
  233. data/lib/state_machine/integrations/base.rb +100 -0
  234. data/lib/state_machine/integrations/data_mapper.rb +511 -0
  235. data/lib/state_machine/integrations/data_mapper/observer.rb +210 -0
  236. data/lib/state_machine/integrations/data_mapper/versions.rb +85 -0
  237. data/lib/state_machine/integrations/mongo_mapper.rb +389 -0
  238. data/lib/state_machine/integrations/mongo_mapper/locale.rb +4 -0
  239. data/lib/state_machine/integrations/mongo_mapper/versions.rb +89 -0
  240. data/lib/state_machine/integrations/mongoid.rb +465 -0
  241. data/lib/state_machine/integrations/mongoid/locale.rb +4 -0
  242. data/lib/state_machine/integrations/mongoid/versions.rb +81 -0
  243. data/lib/state_machine/integrations/sequel.rb +486 -0
  244. data/lib/state_machine/integrations/sequel/versions.rb +95 -0
  245. data/lib/state_machine/machine.rb +2292 -0
  246. data/lib/state_machine/machine_collection.rb +86 -0
  247. data/lib/state_machine/macro_methods.rb +522 -0
  248. data/lib/state_machine/matcher.rb +123 -0
  249. data/lib/state_machine/matcher_helpers.rb +54 -0
  250. data/lib/state_machine/node_collection.rb +222 -0
  251. data/lib/state_machine/path.rb +120 -0
  252. data/lib/state_machine/path_collection.rb +90 -0
  253. data/lib/state_machine/state.rb +297 -0
  254. data/lib/state_machine/state_collection.rb +112 -0
  255. data/lib/state_machine/state_context.rb +138 -0
  256. data/lib/state_machine/transition.rb +470 -0
  257. data/lib/state_machine/transition_collection.rb +245 -0
  258. data/lib/state_machine/version.rb +3 -0
  259. data/lib/state_machine/yard.rb +8 -0
  260. data/lib/state_machine/yard/handlers.rb +12 -0
  261. data/lib/state_machine/yard/handlers/base.rb +32 -0
  262. data/lib/state_machine/yard/handlers/event.rb +25 -0
  263. data/lib/state_machine/yard/handlers/machine.rb +344 -0
  264. data/lib/state_machine/yard/handlers/state.rb +25 -0
  265. data/lib/state_machine/yard/handlers/transition.rb +47 -0
  266. data/lib/state_machine/yard/templates.rb +3 -0
  267. data/lib/state_machine/yard/templates/default/class/html/setup.rb +30 -0
  268. data/lib/state_machine/yard/templates/default/class/html/state_machines.erb +12 -0
  269. data/lib/tasks/state_machine.rake +1 -0
  270. data/lib/tasks/state_machine.rb +30 -0
  271. data/lib/yard-state_machine.rb +2 -0
  272. data/state_machine.gemspec +21 -0
  273. data/test/files/en.yml +17 -0
  274. data/test/files/switch.rb +15 -0
  275. data/test/functional/state_machine_test.rb +1067 -0
  276. data/test/test_helper.rb +8 -0
  277. data/test/unit/assertions_test.rb +40 -0
  278. data/test/unit/branch_test.rb +969 -0
  279. data/test/unit/callback_test.rb +704 -0
  280. data/test/unit/error_test.rb +43 -0
  281. data/test/unit/eval_helpers_test.rb +270 -0
  282. data/test/unit/event_collection_test.rb +398 -0
  283. data/test/unit/event_test.rb +1196 -0
  284. data/test/unit/graph_test.rb +98 -0
  285. data/test/unit/helper_module_test.rb +17 -0
  286. data/test/unit/integrations/active_model_test.rb +1245 -0
  287. data/test/unit/integrations/active_record_test.rb +2551 -0
  288. data/test/unit/integrations/base_test.rb +104 -0
  289. data/test/unit/integrations/data_mapper_test.rb +2194 -0
  290. data/test/unit/integrations/mongo_mapper_test.rb +2026 -0
  291. data/test/unit/integrations/mongoid_test.rb +2309 -0
  292. data/test/unit/integrations/sequel_test.rb +1896 -0
  293. data/test/unit/integrations_test.rb +83 -0
  294. data/test/unit/invalid_event_test.rb +20 -0
  295. data/test/unit/invalid_parallel_transition_test.rb +18 -0
  296. data/test/unit/invalid_transition_test.rb +115 -0
  297. data/test/unit/machine_collection_test.rb +603 -0
  298. data/test/unit/machine_test.rb +3431 -0
  299. data/test/unit/matcher_helpers_test.rb +37 -0
  300. data/test/unit/matcher_test.rb +155 -0
  301. data/test/unit/node_collection_test.rb +362 -0
  302. data/test/unit/path_collection_test.rb +266 -0
  303. data/test/unit/path_test.rb +485 -0
  304. data/test/unit/state_collection_test.rb +352 -0
  305. data/test/unit/state_context_test.rb +441 -0
  306. data/test/unit/state_machine_test.rb +31 -0
  307. data/test/unit/state_test.rb +1101 -0
  308. data/test/unit/transition_collection_test.rb +2168 -0
  309. data/test/unit/transition_test.rb +1558 -0
  310. metadata +451 -0
Binary file
@@ -0,0 +1,2230 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: TrafficLight
8
+
9
+ &mdash; Documentation by YARD 0.7.5
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="_index.html">Index (T)</a> &raquo;
37
+
38
+
39
+ <span class="title">TrafficLight</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: TrafficLight
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Object</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">TrafficLight</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ <dt class="r2 last">Defined in:</dt>
90
+ <dd class="r2 last">traffic_light.rb</dd>
91
+
92
+ </dl>
93
+ <div class="clear"></div>
94
+
95
+ <h2>State Machines</h2>
96
+
97
+ This class contains 1 state machine(s).
98
+
99
+
100
+ <h3>state</h3>
101
+ <p></p>
102
+
103
+
104
+ <img alt="State machine diagram for state" src="TrafficLight_state.png" />
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
112
+ <ul class="summary">
113
+
114
+ <li class="public ">
115
+ <span class="summary_signature">
116
+
117
+ <a href="#state-instance_method" title="#state (instance method)">- (Object) <strong>state</strong> </a>
118
+
119
+
120
+
121
+ </span>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'><p>
134
+ Gets the current attribute value for the machine.
135
+ </p>
136
+ </div></span>
137
+
138
+ </li>
139
+
140
+
141
+ </ul>
142
+
143
+
144
+
145
+
146
+
147
+ <h2>
148
+ Class Method Summary
149
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
150
+ </h2>
151
+
152
+ <ul class="summary">
153
+
154
+ <li class="public ">
155
+ <span class="summary_signature">
156
+
157
+ <a href="#human_state_event_name-class_method" title="human_state_event_name (class method)">+ (String) <strong>human_state_event_name</strong>(event) </a>
158
+
159
+
160
+
161
+ </span>
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+ <span class="summary_desc"><div class='inline'><p>
171
+ Gets the humanized name for the given event.
172
+ </p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ <li class="public ">
179
+ <span class="summary_signature">
180
+
181
+ <a href="#human_state_name-class_method" title="human_state_name (class method)">+ (String) <strong>human_state_name</strong>(state) </a>
182
+
183
+
184
+
185
+ </span>
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+ <span class="summary_desc"><div class='inline'><p>
195
+ Gets the humanized name for the given state.
196
+ </p>
197
+ </div></span>
198
+
199
+ </li>
200
+
201
+
202
+ </ul>
203
+
204
+ <h2>
205
+ Instance Method Summary
206
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
207
+ </h2>
208
+
209
+ <ul class="summary">
210
+
211
+ <li class="public ">
212
+ <span class="summary_signature">
213
+
214
+ <a href="#can_cycle%3F-instance_method" title="#can_cycle? (instance method)">- (Boolean) <strong>can_cycle?</strong>(requirements = {}) </a>
215
+
216
+
217
+
218
+ </span>
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+ <span class="summary_desc"><div class='inline'><p>
228
+ Checks whether :cycle can be fired.
229
+ </p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ <li class="public ">
236
+ <span class="summary_signature">
237
+
238
+ <a href="#caution%3F-instance_method" title="#caution? (instance method)">- (Boolean) <strong>caution?</strong> </a>
239
+
240
+
241
+
242
+ </span>
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+ <span class="summary_desc"><div class='inline'><p>
252
+ Checks whether :caution is the current state.
253
+ </p>
254
+ </div></span>
255
+
256
+ </li>
257
+
258
+
259
+ <li class="public ">
260
+ <span class="summary_signature">
261
+
262
+ <a href="#cycle-instance_method" title="#cycle (instance method)">- (Boolean) <strong>cycle</strong>(*args) </a>
263
+
264
+
265
+
266
+ </span>
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+ <span class="summary_desc"><div class='inline'><p>
276
+ Fires the :cycle event.
277
+ </p>
278
+ </div></span>
279
+
280
+ </li>
281
+
282
+
283
+ <li class="public ">
284
+ <span class="summary_signature">
285
+
286
+ <a href="#cycle%21-instance_method" title="#cycle! (instance method)">- (Boolean) <strong>cycle!</strong>(*args) </a>
287
+
288
+
289
+
290
+ </span>
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ <span class="summary_desc"><div class='inline'><p>
300
+ Fires the :cycle event, raising an exception if it fails.
301
+ </p>
302
+ </div></span>
303
+
304
+ </li>
305
+
306
+
307
+ <li class="public ">
308
+ <span class="summary_signature">
309
+
310
+ <a href="#cycle_transition-instance_method" title="#cycle_transition (instance method)">- (StateMachine::Transition) <strong>cycle_transition</strong>(requirements = {}) </a>
311
+
312
+
313
+
314
+ </span>
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+ <span class="summary_desc"><div class='inline'><p>
324
+ Gets the next transition that would be performed if :cycle were to be
325
+ fired.
326
+ </p>
327
+ </div></span>
328
+
329
+ </li>
330
+
331
+
332
+ <li class="public ">
333
+ <span class="summary_signature">
334
+
335
+ <a href="#fire_state_event-instance_method" title="#fire_state_event (instance method)">- (Boolean) <strong>fire_state_event</strong>(event, *args) </a>
336
+
337
+
338
+
339
+ </span>
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+ <span class="summary_desc"><div class='inline'><p>
349
+ Fires an arbitrary state event with the given argument list.
350
+ </p>
351
+ </div></span>
352
+
353
+ </li>
354
+
355
+
356
+ <li class="public ">
357
+ <span class="summary_signature">
358
+
359
+ <a href="#human_state_name-instance_method" title="#human_state_name (instance method)">- (String) <strong>human_state_name</strong> </a>
360
+
361
+
362
+
363
+ </span>
364
+
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+ <span class="summary_desc"><div class='inline'><p>
373
+ Gets the human-readable name of the state for the current value.
374
+ </p>
375
+ </div></span>
376
+
377
+ </li>
378
+
379
+
380
+ <li class="public ">
381
+ <span class="summary_signature">
382
+
383
+ <a href="#proceed%3F-instance_method" title="#proceed? (instance method)">- (Boolean) <strong>proceed?</strong> </a>
384
+
385
+
386
+
387
+ </span>
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+ <span class="summary_desc"><div class='inline'><p>
397
+ Checks whether :proceed is the current state.
398
+ </p>
399
+ </div></span>
400
+
401
+ </li>
402
+
403
+
404
+ <li class="public ">
405
+ <span class="summary_signature">
406
+
407
+ <a href="#state%3F-instance_method" title="#state? (instance method)">- (Boolean) <strong>state?</strong>(state_name) </a>
408
+
409
+
410
+
411
+ </span>
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+ <span class="summary_desc"><div class='inline'><p>
421
+ Checks the given state name against the current state.
422
+ </p>
423
+ </div></span>
424
+
425
+ </li>
426
+
427
+
428
+ <li class="public ">
429
+ <span class="summary_signature">
430
+
431
+ <a href="#state_events-instance_method" title="#state_events (instance method)">- (Array&lt;Symbol&gt;) <strong>state_events</strong>(requirements = {}) </a>
432
+
433
+
434
+
435
+ </span>
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+ <span class="summary_desc"><div class='inline'><p>
445
+ Gets the list of events that can be fired on the current state (uses the
446
+ <b>unqualified</b> event names).
447
+ </p>
448
+ </div></span>
449
+
450
+ </li>
451
+
452
+
453
+ <li class="public ">
454
+ <span class="summary_signature">
455
+
456
+ <a href="#state_name-instance_method" title="#state_name (instance method)">- (Symbol) <strong>state_name</strong> </a>
457
+
458
+
459
+
460
+ </span>
461
+
462
+
463
+
464
+
465
+
466
+
467
+
468
+
469
+ <span class="summary_desc"><div class='inline'><p>
470
+ Gets the internal name of the state for the current value.
471
+ </p>
472
+ </div></span>
473
+
474
+ </li>
475
+
476
+
477
+ <li class="public ">
478
+ <span class="summary_signature">
479
+
480
+ <a href="#state_paths-instance_method" title="#state_paths (instance method)">- (StateMachine::PathCollection) <strong>state_paths</strong>(requirements = {}) </a>
481
+
482
+
483
+
484
+ </span>
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+ <span class="summary_desc"><div class='inline'><p>
494
+ Gets the list of sequences of transitions that can be run for the current
495
+ state.
496
+ </p>
497
+ </div></span>
498
+
499
+ </li>
500
+
501
+
502
+ <li class="public ">
503
+ <span class="summary_signature">
504
+
505
+ <a href="#state_transitions-instance_method" title="#state_transitions (instance method)">- (Array&lt;StateMachine::Transition&gt;) <strong>state_transitions</strong>(requirements = {}) </a>
506
+
507
+
508
+
509
+ </span>
510
+
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+ <span class="summary_desc"><div class='inline'><p>
519
+ Gets the list of transitions that can be made for the current state.
520
+ </p>
521
+ </div></span>
522
+
523
+ </li>
524
+
525
+
526
+ <li class="public ">
527
+ <span class="summary_signature">
528
+
529
+ <a href="#stop%3F-instance_method" title="#stop? (instance method)">- (Boolean) <strong>stop?</strong> </a>
530
+
531
+
532
+
533
+ </span>
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+ <span class="summary_desc"><div class='inline'><p>
543
+ Checks whether :stop is the current state.
544
+ </p>
545
+ </div></span>
546
+
547
+ </li>
548
+
549
+
550
+ </ul>
551
+
552
+
553
+
554
+ <div id="instance_attr_details" class="attr_details">
555
+ <h2>Instance Attribute Details</h2>
556
+
557
+
558
+ <span id="state=-instance_method"></span>
559
+ <span id="state-instance_method"></span>
560
+ <div class="method_details first">
561
+ <p class="signature first" id="state-instance_method">
562
+
563
+ - (<tt>Object</tt>) <strong>state</strong>
564
+
565
+
566
+
567
+ </p><div class="docstring">
568
+ <div class="discussion">
569
+ <p>
570
+ Gets the current attribute value for the machine
571
+ </p>
572
+
573
+
574
+ </div>
575
+ </div>
576
+ <div class="tags">
577
+
578
+ <h3>Returns:</h3>
579
+ <ul class="return">
580
+
581
+ <li>
582
+
583
+
584
+ <span class='type'></span>
585
+
586
+
587
+
588
+
589
+ <div class='inline'><p>
590
+ The attribute value
591
+ </p>
592
+ </div>
593
+
594
+ </li>
595
+
596
+ </ul>
597
+
598
+ </div><table class="source_code">
599
+ <tr>
600
+ <td>
601
+ <pre class="lines">
602
+
603
+
604
+ 4
605
+ 5
606
+ 6
607
+ 7
608
+ 8</pre>
609
+ </td>
610
+ <td>
611
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
612
+
613
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
614
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
615
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
616
+ <span class='kw'>end</span>
617
+ <span class='kw'>end</span></pre>
618
+ </td>
619
+ </tr>
620
+ </table>
621
+ </div>
622
+
623
+ </div>
624
+
625
+
626
+ <div id="class_method_details" class="method_details_list">
627
+ <h2>Class Method Details</h2>
628
+
629
+
630
+ <div class="method_details first">
631
+ <p class="signature first" id="human_state_event_name-class_method">
632
+
633
+ + (<tt>String</tt>) <strong>human_state_event_name</strong>(event)
634
+
635
+
636
+
637
+ </p><div class="docstring">
638
+ <div class="discussion">
639
+ <p>
640
+ Gets the humanized name for the given event.
641
+ </p>
642
+
643
+
644
+ </div>
645
+ </div>
646
+ <div class="tags">
647
+ <h3>Parameters:</h3>
648
+ <ul class="param">
649
+
650
+ <li>
651
+
652
+ <span class='name'>event</span>
653
+
654
+
655
+ <span class='type'>(<tt>Symbol</tt>)</span>
656
+
657
+
658
+
659
+ &mdash;
660
+ <div class='inline'><p>
661
+ The event to look up
662
+ </p>
663
+ </div>
664
+
665
+ </li>
666
+
667
+ </ul>
668
+
669
+ <h3>Returns:</h3>
670
+ <ul class="return">
671
+
672
+ <li>
673
+
674
+
675
+ <span class='type'>(<tt>String</tt>)</span>
676
+
677
+
678
+
679
+ &mdash;
680
+ <div class='inline'><p>
681
+ The human event name
682
+ </p>
683
+ </div>
684
+
685
+ </li>
686
+
687
+ </ul>
688
+
689
+ </div><table class="source_code">
690
+ <tr>
691
+ <td>
692
+ <pre class="lines">
693
+
694
+
695
+ 4
696
+ 5
697
+ 6
698
+ 7
699
+ 8</pre>
700
+ </td>
701
+ <td>
702
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
703
+
704
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
705
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
706
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
707
+ <span class='kw'>end</span>
708
+ <span class='kw'>end</span></pre>
709
+ </td>
710
+ </tr>
711
+ </table>
712
+ </div>
713
+
714
+ <div class="method_details ">
715
+ <p class="signature " id="human_state_name-class_method">
716
+
717
+ + (<tt>String</tt>) <strong>human_state_name</strong>(state)
718
+
719
+
720
+
721
+ </p><div class="docstring">
722
+ <div class="discussion">
723
+ <p>
724
+ Gets the humanized name for the given state.
725
+ </p>
726
+
727
+
728
+ </div>
729
+ </div>
730
+ <div class="tags">
731
+ <h3>Parameters:</h3>
732
+ <ul class="param">
733
+
734
+ <li>
735
+
736
+ <span class='name'>state</span>
737
+
738
+
739
+ <span class='type'>(<tt>Symbol</tt>)</span>
740
+
741
+
742
+
743
+ &mdash;
744
+ <div class='inline'><p>
745
+ The state to look up
746
+ </p>
747
+ </div>
748
+
749
+ </li>
750
+
751
+ </ul>
752
+
753
+ <h3>Returns:</h3>
754
+ <ul class="return">
755
+
756
+ <li>
757
+
758
+
759
+ <span class='type'>(<tt>String</tt>)</span>
760
+
761
+
762
+
763
+ &mdash;
764
+ <div class='inline'><p>
765
+ The human state name
766
+ </p>
767
+ </div>
768
+
769
+ </li>
770
+
771
+ </ul>
772
+
773
+ </div><table class="source_code">
774
+ <tr>
775
+ <td>
776
+ <pre class="lines">
777
+
778
+
779
+ 4
780
+ 5
781
+ 6
782
+ 7
783
+ 8</pre>
784
+ </td>
785
+ <td>
786
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
787
+
788
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
789
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
790
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
791
+ <span class='kw'>end</span>
792
+ <span class='kw'>end</span></pre>
793
+ </td>
794
+ </tr>
795
+ </table>
796
+ </div>
797
+
798
+ </div>
799
+
800
+ <div id="instance_method_details" class="method_details_list">
801
+ <h2>Instance Method Details</h2>
802
+
803
+
804
+ <div class="method_details first">
805
+ <p class="signature first" id="can_cycle?-instance_method">
806
+
807
+ - (<tt>Boolean</tt>) <strong>can_cycle?</strong>(requirements = {})
808
+
809
+
810
+
811
+ </p><div class="docstring">
812
+ <div class="discussion">
813
+ <p>
814
+ Checks whether :cycle can be fired.
815
+ </p>
816
+
817
+
818
+ </div>
819
+ </div>
820
+ <div class="tags">
821
+ <h3>Parameters:</h3>
822
+ <ul class="param">
823
+
824
+ <li>
825
+
826
+ <span class='name'>requirements</span>
827
+
828
+
829
+ <span class='type'>(<tt>Hash</tt>)</span>
830
+
831
+
832
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
833
+
834
+
835
+ &mdash;
836
+ <div class='inline'><p>
837
+ The transition requirements to test against
838
+ </p>
839
+ </div>
840
+
841
+ </li>
842
+
843
+ </ul>
844
+
845
+
846
+
847
+
848
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
849
+ <ul class="option">
850
+
851
+ <li>
852
+ <span class="name">:from</span>
853
+ <span class="type">(<tt>Symbol</tt>)</span>
854
+ <span class="default">
855
+
856
+ &mdash; default:
857
+ <tt>the current state</tt>
858
+
859
+ </span>
860
+ &mdash; <div class='inline'><p>
861
+ One or more initial states
862
+ </p>
863
+ </div>
864
+ </li>
865
+
866
+ <li>
867
+ <span class="name">:to</span>
868
+ <span class="type">(<tt>Symbol</tt>)</span>
869
+ <span class="default">
870
+
871
+ </span>
872
+ &mdash; <div class='inline'><p>
873
+ One or more target states
874
+ </p>
875
+ </div>
876
+ </li>
877
+
878
+ <li>
879
+ <span class="name">:guard</span>
880
+ <span class="type">(<tt>Boolean</tt>)</span>
881
+ <span class="default">
882
+
883
+ </span>
884
+ &mdash; <div class='inline'><p>
885
+ Whether to guard transitions with conditionals
886
+ </p>
887
+ </div>
888
+ </li>
889
+
890
+ </ul>
891
+
892
+
893
+ <h3>Returns:</h3>
894
+ <ul class="return">
895
+
896
+ <li>
897
+
898
+
899
+ <span class='type'>(<tt>Boolean</tt>)</span>
900
+
901
+
902
+
903
+ &mdash;
904
+ <div class='inline'><p>
905
+ <tt>true</tt> if :cycle can be fired, otherwise <tt>false</tt>
906
+ </p>
907
+ </div>
908
+
909
+ </li>
910
+
911
+ </ul>
912
+
913
+ </div><table class="source_code">
914
+ <tr>
915
+ <td>
916
+ <pre class="lines">
917
+
918
+
919
+ 4
920
+ 5
921
+ 6
922
+ 7
923
+ 8</pre>
924
+ </td>
925
+ <td>
926
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
927
+
928
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
929
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
930
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
931
+ <span class='kw'>end</span>
932
+ <span class='kw'>end</span></pre>
933
+ </td>
934
+ </tr>
935
+ </table>
936
+ </div>
937
+
938
+ <div class="method_details ">
939
+ <p class="signature " id="caution?-instance_method">
940
+
941
+ - (<tt>Boolean</tt>) <strong>caution?</strong>
942
+
943
+
944
+
945
+ </p><div class="docstring">
946
+ <div class="discussion">
947
+ <p>
948
+ Checks whether :caution is the current state.
949
+ </p>
950
+
951
+
952
+ </div>
953
+ </div>
954
+ <div class="tags">
955
+
956
+ <h3>Returns:</h3>
957
+ <ul class="return">
958
+
959
+ <li>
960
+
961
+
962
+ <span class='type'>(<tt>Boolean</tt>)</span>
963
+
964
+
965
+
966
+ &mdash;
967
+ <div class='inline'><p>
968
+ <tt>true</tt> if this is the current state, otherwise <tt>false</tt>
969
+ </p>
970
+ </div>
971
+
972
+ </li>
973
+
974
+ </ul>
975
+
976
+ </div><table class="source_code">
977
+ <tr>
978
+ <td>
979
+ <pre class="lines">
980
+
981
+
982
+ 4
983
+ 5
984
+ 6
985
+ 7
986
+ 8</pre>
987
+ </td>
988
+ <td>
989
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
990
+
991
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
992
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
993
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
994
+ <span class='kw'>end</span>
995
+ <span class='kw'>end</span></pre>
996
+ </td>
997
+ </tr>
998
+ </table>
999
+ </div>
1000
+
1001
+ <div class="method_details ">
1002
+ <p class="signature " id="cycle-instance_method">
1003
+
1004
+ - (<tt>Boolean</tt>) <strong>cycle</strong>(*args)
1005
+
1006
+
1007
+
1008
+ </p><div class="docstring">
1009
+ <div class="discussion">
1010
+ <p>
1011
+ Fires the :cycle event.
1012
+ </p>
1013
+
1014
+
1015
+ </div>
1016
+ </div>
1017
+ <div class="tags">
1018
+ <h3>Parameters:</h3>
1019
+ <ul class="param">
1020
+
1021
+ <li>
1022
+
1023
+ <span class='name'>args</span>
1024
+
1025
+
1026
+ <span class='type'>(<tt>Array</tt>)</span>
1027
+
1028
+
1029
+
1030
+ &mdash;
1031
+ <div class='inline'><p>
1032
+ Optional arguments to include in transition callbacks
1033
+ </p>
1034
+ </div>
1035
+
1036
+ </li>
1037
+
1038
+ </ul>
1039
+
1040
+ <h3>Returns:</h3>
1041
+ <ul class="return">
1042
+
1043
+ <li>
1044
+
1045
+
1046
+ <span class='type'>(<tt>Boolean</tt>)</span>
1047
+
1048
+
1049
+
1050
+ &mdash;
1051
+ <div class='inline'><p>
1052
+ <tt>true</tt> if the transition succeeds, otherwise <tt>false</tt>
1053
+ </p>
1054
+ </div>
1055
+
1056
+ </li>
1057
+
1058
+ </ul>
1059
+
1060
+ </div><table class="source_code">
1061
+ <tr>
1062
+ <td>
1063
+ <pre class="lines">
1064
+
1065
+
1066
+ 4
1067
+ 5
1068
+ 6
1069
+ 7
1070
+ 8</pre>
1071
+ </td>
1072
+ <td>
1073
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1074
+
1075
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1076
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1077
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1078
+ <span class='kw'>end</span>
1079
+ <span class='kw'>end</span></pre>
1080
+ </td>
1081
+ </tr>
1082
+ </table>
1083
+ </div>
1084
+
1085
+ <div class="method_details ">
1086
+ <p class="signature " id="cycle!-instance_method">
1087
+
1088
+ - (<tt>Boolean</tt>) <strong>cycle!</strong>(*args)
1089
+
1090
+
1091
+
1092
+ </p><div class="docstring">
1093
+ <div class="discussion">
1094
+ <p>
1095
+ Fires the :cycle event, raising an exception if it fails.
1096
+ </p>
1097
+
1098
+
1099
+ </div>
1100
+ </div>
1101
+ <div class="tags">
1102
+ <h3>Parameters:</h3>
1103
+ <ul class="param">
1104
+
1105
+ <li>
1106
+
1107
+ <span class='name'>args</span>
1108
+
1109
+
1110
+ <span class='type'>(<tt>Array</tt>)</span>
1111
+
1112
+
1113
+
1114
+ &mdash;
1115
+ <div class='inline'><p>
1116
+ Optional arguments to include in transition callbacks
1117
+ </p>
1118
+ </div>
1119
+
1120
+ </li>
1121
+
1122
+ </ul>
1123
+
1124
+ <h3>Returns:</h3>
1125
+ <ul class="return">
1126
+
1127
+ <li>
1128
+
1129
+
1130
+ <span class='type'>(<tt>Boolean</tt>)</span>
1131
+
1132
+
1133
+
1134
+ &mdash;
1135
+ <div class='inline'><p>
1136
+ <tt>true</tt> if the transition succeeds
1137
+ </p>
1138
+ </div>
1139
+
1140
+ </li>
1141
+
1142
+ </ul>
1143
+ <h3>Raises:</h3>
1144
+ <ul class="raise">
1145
+
1146
+ <li>
1147
+
1148
+
1149
+ <span class='type'>(<tt>StateMachine::InvalidTransition</tt>)</span>
1150
+
1151
+
1152
+
1153
+ &mdash;
1154
+ <div class='inline'><p>
1155
+ If the transition fails
1156
+ </p>
1157
+ </div>
1158
+
1159
+ </li>
1160
+
1161
+ </ul>
1162
+
1163
+ </div><table class="source_code">
1164
+ <tr>
1165
+ <td>
1166
+ <pre class="lines">
1167
+
1168
+
1169
+ 4
1170
+ 5
1171
+ 6
1172
+ 7
1173
+ 8</pre>
1174
+ </td>
1175
+ <td>
1176
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1177
+
1178
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1179
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1180
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1181
+ <span class='kw'>end</span>
1182
+ <span class='kw'>end</span></pre>
1183
+ </td>
1184
+ </tr>
1185
+ </table>
1186
+ </div>
1187
+
1188
+ <div class="method_details ">
1189
+ <p class="signature " id="cycle_transition-instance_method">
1190
+
1191
+ - (<tt>StateMachine::Transition</tt>) <strong>cycle_transition</strong>(requirements = {})
1192
+
1193
+
1194
+
1195
+ </p><div class="docstring">
1196
+ <div class="discussion">
1197
+ <p>
1198
+ Gets the next transition that would be performed if :cycle were to be
1199
+ fired.
1200
+ </p>
1201
+
1202
+
1203
+ </div>
1204
+ </div>
1205
+ <div class="tags">
1206
+ <h3>Parameters:</h3>
1207
+ <ul class="param">
1208
+
1209
+ <li>
1210
+
1211
+ <span class='name'>requirements</span>
1212
+
1213
+
1214
+ <span class='type'>(<tt>Hash</tt>)</span>
1215
+
1216
+
1217
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1218
+
1219
+
1220
+ &mdash;
1221
+ <div class='inline'><p>
1222
+ The transition requirements to test against
1223
+ </p>
1224
+ </div>
1225
+
1226
+ </li>
1227
+
1228
+ </ul>
1229
+
1230
+
1231
+
1232
+
1233
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
1234
+ <ul class="option">
1235
+
1236
+ <li>
1237
+ <span class="name">:from</span>
1238
+ <span class="type">(<tt>Symbol</tt>)</span>
1239
+ <span class="default">
1240
+
1241
+ &mdash; default:
1242
+ <tt>the current state</tt>
1243
+
1244
+ </span>
1245
+ &mdash; <div class='inline'><p>
1246
+ One or more initial states
1247
+ </p>
1248
+ </div>
1249
+ </li>
1250
+
1251
+ <li>
1252
+ <span class="name">:to</span>
1253
+ <span class="type">(<tt>Symbol</tt>)</span>
1254
+ <span class="default">
1255
+
1256
+ </span>
1257
+ &mdash; <div class='inline'><p>
1258
+ One or more target states
1259
+ </p>
1260
+ </div>
1261
+ </li>
1262
+
1263
+ <li>
1264
+ <span class="name">:guard</span>
1265
+ <span class="type">(<tt>Boolean</tt>)</span>
1266
+ <span class="default">
1267
+
1268
+ </span>
1269
+ &mdash; <div class='inline'><p>
1270
+ Whether to guard transitions with conditionals
1271
+ </p>
1272
+ </div>
1273
+ </li>
1274
+
1275
+ </ul>
1276
+
1277
+
1278
+ <h3>Returns:</h3>
1279
+ <ul class="return">
1280
+
1281
+ <li>
1282
+
1283
+
1284
+ <span class='type'>(<tt>StateMachine::Transition</tt>)</span>
1285
+
1286
+
1287
+
1288
+ &mdash;
1289
+ <div class='inline'><p>
1290
+ The transition that would be performed or <tt>nil</tt>
1291
+ </p>
1292
+ </div>
1293
+
1294
+ </li>
1295
+
1296
+ </ul>
1297
+
1298
+ </div><table class="source_code">
1299
+ <tr>
1300
+ <td>
1301
+ <pre class="lines">
1302
+
1303
+
1304
+ 4
1305
+ 5
1306
+ 6
1307
+ 7
1308
+ 8</pre>
1309
+ </td>
1310
+ <td>
1311
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1312
+
1313
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1314
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1315
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1316
+ <span class='kw'>end</span>
1317
+ <span class='kw'>end</span></pre>
1318
+ </td>
1319
+ </tr>
1320
+ </table>
1321
+ </div>
1322
+
1323
+ <div class="method_details ">
1324
+ <p class="signature " id="fire_state_event-instance_method">
1325
+
1326
+ - (<tt>Boolean</tt>) <strong>fire_state_event</strong>(event, *args)
1327
+
1328
+
1329
+
1330
+ </p><div class="docstring">
1331
+ <div class="discussion">
1332
+ <p>
1333
+ Fires an arbitrary state event with the given argument list
1334
+ </p>
1335
+
1336
+
1337
+ </div>
1338
+ </div>
1339
+ <div class="tags">
1340
+ <h3>Parameters:</h3>
1341
+ <ul class="param">
1342
+
1343
+ <li>
1344
+
1345
+ <span class='name'>event</span>
1346
+
1347
+
1348
+ <span class='type'>(<tt>Symbol</tt>)</span>
1349
+
1350
+
1351
+
1352
+ &mdash;
1353
+ <div class='inline'><p>
1354
+ The name of the event to fire
1355
+ </p>
1356
+ </div>
1357
+
1358
+ </li>
1359
+
1360
+ <li>
1361
+
1362
+ <span class='name'>args</span>
1363
+
1364
+
1365
+ <span class='type'></span>
1366
+
1367
+
1368
+
1369
+ &mdash;
1370
+ <div class='inline'><p>
1371
+ Optional arguments to include in the transition
1372
+ </p>
1373
+ </div>
1374
+
1375
+ </li>
1376
+
1377
+ </ul>
1378
+
1379
+ <h3>Returns:</h3>
1380
+ <ul class="return">
1381
+
1382
+ <li>
1383
+
1384
+
1385
+ <span class='type'>(<tt>Boolean</tt>)</span>
1386
+
1387
+
1388
+
1389
+ &mdash;
1390
+ <div class='inline'><p>
1391
+ <tt>true</tt> if the event succeeds, otherwise <tt>false</tt>
1392
+ </p>
1393
+ </div>
1394
+
1395
+ </li>
1396
+
1397
+ </ul>
1398
+
1399
+ </div><table class="source_code">
1400
+ <tr>
1401
+ <td>
1402
+ <pre class="lines">
1403
+
1404
+
1405
+ 4
1406
+ 5
1407
+ 6
1408
+ 7
1409
+ 8</pre>
1410
+ </td>
1411
+ <td>
1412
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1413
+
1414
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1415
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1416
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1417
+ <span class='kw'>end</span>
1418
+ <span class='kw'>end</span></pre>
1419
+ </td>
1420
+ </tr>
1421
+ </table>
1422
+ </div>
1423
+
1424
+ <div class="method_details ">
1425
+ <p class="signature " id="human_state_name-instance_method">
1426
+
1427
+ - (<tt>String</tt>) <strong>human_state_name</strong>
1428
+
1429
+
1430
+
1431
+ </p><div class="docstring">
1432
+ <div class="discussion">
1433
+ <p>
1434
+ Gets the human-readable name of the state for the current value.
1435
+ </p>
1436
+
1437
+
1438
+ </div>
1439
+ </div>
1440
+ <div class="tags">
1441
+
1442
+ <h3>Returns:</h3>
1443
+ <ul class="return">
1444
+
1445
+ <li>
1446
+
1447
+
1448
+ <span class='type'>(<tt>String</tt>)</span>
1449
+
1450
+
1451
+
1452
+ &mdash;
1453
+ <div class='inline'><p>
1454
+ The human-readable state name
1455
+ </p>
1456
+ </div>
1457
+
1458
+ </li>
1459
+
1460
+ </ul>
1461
+
1462
+ </div><table class="source_code">
1463
+ <tr>
1464
+ <td>
1465
+ <pre class="lines">
1466
+
1467
+
1468
+ 4
1469
+ 5
1470
+ 6
1471
+ 7
1472
+ 8</pre>
1473
+ </td>
1474
+ <td>
1475
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1476
+
1477
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1478
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1479
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1480
+ <span class='kw'>end</span>
1481
+ <span class='kw'>end</span></pre>
1482
+ </td>
1483
+ </tr>
1484
+ </table>
1485
+ </div>
1486
+
1487
+ <div class="method_details ">
1488
+ <p class="signature " id="proceed?-instance_method">
1489
+
1490
+ - (<tt>Boolean</tt>) <strong>proceed?</strong>
1491
+
1492
+
1493
+
1494
+ </p><div class="docstring">
1495
+ <div class="discussion">
1496
+ <p>
1497
+ Checks whether :proceed is the current state.
1498
+ </p>
1499
+
1500
+
1501
+ </div>
1502
+ </div>
1503
+ <div class="tags">
1504
+
1505
+ <h3>Returns:</h3>
1506
+ <ul class="return">
1507
+
1508
+ <li>
1509
+
1510
+
1511
+ <span class='type'>(<tt>Boolean</tt>)</span>
1512
+
1513
+
1514
+
1515
+ &mdash;
1516
+ <div class='inline'><p>
1517
+ <tt>true</tt> if this is the current state, otherwise <tt>false</tt>
1518
+ </p>
1519
+ </div>
1520
+
1521
+ </li>
1522
+
1523
+ </ul>
1524
+
1525
+ </div><table class="source_code">
1526
+ <tr>
1527
+ <td>
1528
+ <pre class="lines">
1529
+
1530
+
1531
+ 4
1532
+ 5
1533
+ 6
1534
+ 7
1535
+ 8</pre>
1536
+ </td>
1537
+ <td>
1538
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1539
+
1540
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1541
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1542
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1543
+ <span class='kw'>end</span>
1544
+ <span class='kw'>end</span></pre>
1545
+ </td>
1546
+ </tr>
1547
+ </table>
1548
+ </div>
1549
+
1550
+ <div class="method_details ">
1551
+ <p class="signature " id="state?-instance_method">
1552
+
1553
+ - (<tt>Boolean</tt>) <strong>state?</strong>(state_name)
1554
+
1555
+
1556
+
1557
+ </p><div class="docstring">
1558
+ <div class="discussion">
1559
+ <p>
1560
+ Checks the given state name against the current state.
1561
+ </p>
1562
+
1563
+
1564
+ </div>
1565
+ </div>
1566
+ <div class="tags">
1567
+ <h3>Parameters:</h3>
1568
+ <ul class="param">
1569
+
1570
+ <li>
1571
+
1572
+ <span class='name'>state_name</span>
1573
+
1574
+
1575
+ <span class='type'>(<tt>Symbol</tt>)</span>
1576
+
1577
+
1578
+
1579
+ &mdash;
1580
+ <div class='inline'><p>
1581
+ The name of the state to check
1582
+ </p>
1583
+ </div>
1584
+
1585
+ </li>
1586
+
1587
+ </ul>
1588
+
1589
+ <h3>Returns:</h3>
1590
+ <ul class="return">
1591
+
1592
+ <li>
1593
+
1594
+
1595
+ <span class='type'>(<tt>Boolean</tt>)</span>
1596
+
1597
+
1598
+
1599
+ &mdash;
1600
+ <div class='inline'><p>
1601
+ True if they are the same state, otherwise false
1602
+ </p>
1603
+ </div>
1604
+
1605
+ </li>
1606
+
1607
+ </ul>
1608
+ <h3>Raises:</h3>
1609
+ <ul class="raise">
1610
+
1611
+ <li>
1612
+
1613
+
1614
+ <span class='type'>(<tt>IndexError</tt>)</span>
1615
+
1616
+
1617
+
1618
+ &mdash;
1619
+ <div class='inline'><p>
1620
+ If the state name is invalid
1621
+ </p>
1622
+ </div>
1623
+
1624
+ </li>
1625
+
1626
+ </ul>
1627
+
1628
+ </div><table class="source_code">
1629
+ <tr>
1630
+ <td>
1631
+ <pre class="lines">
1632
+
1633
+
1634
+ 4
1635
+ 5
1636
+ 6
1637
+ 7
1638
+ 8</pre>
1639
+ </td>
1640
+ <td>
1641
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1642
+
1643
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1644
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1645
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1646
+ <span class='kw'>end</span>
1647
+ <span class='kw'>end</span></pre>
1648
+ </td>
1649
+ </tr>
1650
+ </table>
1651
+ </div>
1652
+
1653
+ <div class="method_details ">
1654
+ <p class="signature " id="state_events-instance_method">
1655
+
1656
+ - (<tt>Array&lt;Symbol&gt;</tt>) <strong>state_events</strong>(requirements = {})
1657
+
1658
+
1659
+
1660
+ </p><div class="docstring">
1661
+ <div class="discussion">
1662
+ <p>
1663
+ Gets the list of events that can be fired on the current state (uses the
1664
+ <b>unqualified</b> event names)
1665
+ </p>
1666
+
1667
+
1668
+ </div>
1669
+ </div>
1670
+ <div class="tags">
1671
+ <h3>Parameters:</h3>
1672
+ <ul class="param">
1673
+
1674
+ <li>
1675
+
1676
+ <span class='name'>requirements</span>
1677
+
1678
+
1679
+ <span class='type'>(<tt>Hash</tt>)</span>
1680
+
1681
+
1682
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1683
+
1684
+
1685
+ &mdash;
1686
+ <div class='inline'><p>
1687
+ The transition requirements to test against
1688
+ </p>
1689
+ </div>
1690
+
1691
+ </li>
1692
+
1693
+ </ul>
1694
+
1695
+
1696
+
1697
+
1698
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
1699
+ <ul class="option">
1700
+
1701
+ <li>
1702
+ <span class="name">:from</span>
1703
+ <span class="type">(<tt>Symbol</tt>)</span>
1704
+ <span class="default">
1705
+
1706
+ &mdash; default:
1707
+ <tt>the current state</tt>
1708
+
1709
+ </span>
1710
+ &mdash; <div class='inline'><p>
1711
+ One or more initial states
1712
+ </p>
1713
+ </div>
1714
+ </li>
1715
+
1716
+ <li>
1717
+ <span class="name">:to</span>
1718
+ <span class="type">(<tt>Symbol</tt>)</span>
1719
+ <span class="default">
1720
+
1721
+ </span>
1722
+ &mdash; <div class='inline'><p>
1723
+ One or more target states
1724
+ </p>
1725
+ </div>
1726
+ </li>
1727
+
1728
+ <li>
1729
+ <span class="name">:on</span>
1730
+ <span class="type">(<tt>Symbol</tt>)</span>
1731
+ <span class="default">
1732
+
1733
+ </span>
1734
+ &mdash; <div class='inline'><p>
1735
+ One or more events that fire the transition
1736
+ </p>
1737
+ </div>
1738
+ </li>
1739
+
1740
+ <li>
1741
+ <span class="name">:guard</span>
1742
+ <span class="type">(<tt>Boolean</tt>)</span>
1743
+ <span class="default">
1744
+
1745
+ </span>
1746
+ &mdash; <div class='inline'><p>
1747
+ Whether to guard transitions with conditionals
1748
+ </p>
1749
+ </div>
1750
+ </li>
1751
+
1752
+ </ul>
1753
+
1754
+
1755
+ <h3>Returns:</h3>
1756
+ <ul class="return">
1757
+
1758
+ <li>
1759
+
1760
+
1761
+ <span class='type'>(<tt>Array&lt;Symbol&gt;</tt>)</span>
1762
+
1763
+
1764
+
1765
+ &mdash;
1766
+ <div class='inline'><p>
1767
+ The list of event names
1768
+ </p>
1769
+ </div>
1770
+
1771
+ </li>
1772
+
1773
+ </ul>
1774
+
1775
+ </div><table class="source_code">
1776
+ <tr>
1777
+ <td>
1778
+ <pre class="lines">
1779
+
1780
+
1781
+ 4
1782
+ 5
1783
+ 6
1784
+ 7
1785
+ 8</pre>
1786
+ </td>
1787
+ <td>
1788
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1789
+
1790
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1791
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1792
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1793
+ <span class='kw'>end</span>
1794
+ <span class='kw'>end</span></pre>
1795
+ </td>
1796
+ </tr>
1797
+ </table>
1798
+ </div>
1799
+
1800
+ <div class="method_details ">
1801
+ <p class="signature " id="state_name-instance_method">
1802
+
1803
+ - (<tt>Symbol</tt>) <strong>state_name</strong>
1804
+
1805
+
1806
+
1807
+ </p><div class="docstring">
1808
+ <div class="discussion">
1809
+ <p>
1810
+ Gets the internal name of the state for the current value.
1811
+ </p>
1812
+
1813
+
1814
+ </div>
1815
+ </div>
1816
+ <div class="tags">
1817
+
1818
+ <h3>Returns:</h3>
1819
+ <ul class="return">
1820
+
1821
+ <li>
1822
+
1823
+
1824
+ <span class='type'>(<tt>Symbol</tt>)</span>
1825
+
1826
+
1827
+
1828
+ &mdash;
1829
+ <div class='inline'><p>
1830
+ The internal name of the state
1831
+ </p>
1832
+ </div>
1833
+
1834
+ </li>
1835
+
1836
+ </ul>
1837
+
1838
+ </div><table class="source_code">
1839
+ <tr>
1840
+ <td>
1841
+ <pre class="lines">
1842
+
1843
+
1844
+ 4
1845
+ 5
1846
+ 6
1847
+ 7
1848
+ 8</pre>
1849
+ </td>
1850
+ <td>
1851
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1852
+
1853
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
1854
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
1855
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
1856
+ <span class='kw'>end</span>
1857
+ <span class='kw'>end</span></pre>
1858
+ </td>
1859
+ </tr>
1860
+ </table>
1861
+ </div>
1862
+
1863
+ <div class="method_details ">
1864
+ <p class="signature " id="state_paths-instance_method">
1865
+
1866
+ - (<tt>StateMachine::PathCollection</tt>) <strong>state_paths</strong>(requirements = {})
1867
+
1868
+
1869
+
1870
+ </p><div class="docstring">
1871
+ <div class="discussion">
1872
+ <p>
1873
+ Gets the list of sequences of transitions that can be run for the current
1874
+ state
1875
+ </p>
1876
+
1877
+
1878
+ </div>
1879
+ </div>
1880
+ <div class="tags">
1881
+ <h3>Parameters:</h3>
1882
+ <ul class="param">
1883
+
1884
+ <li>
1885
+
1886
+ <span class='name'>requirements</span>
1887
+
1888
+
1889
+ <span class='type'>(<tt>Hash</tt>)</span>
1890
+
1891
+
1892
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1893
+
1894
+
1895
+ &mdash;
1896
+ <div class='inline'><p>
1897
+ The transition requirements to test against
1898
+ </p>
1899
+ </div>
1900
+
1901
+ </li>
1902
+
1903
+ </ul>
1904
+
1905
+
1906
+
1907
+
1908
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
1909
+ <ul class="option">
1910
+
1911
+ <li>
1912
+ <span class="name">:from</span>
1913
+ <span class="type">(<tt>Symbol</tt>)</span>
1914
+ <span class="default">
1915
+
1916
+ &mdash; default:
1917
+ <tt>the current state</tt>
1918
+
1919
+ </span>
1920
+ &mdash; <div class='inline'><p>
1921
+ The initial state
1922
+ </p>
1923
+ </div>
1924
+ </li>
1925
+
1926
+ <li>
1927
+ <span class="name">:to</span>
1928
+ <span class="type">(<tt>Symbol</tt>)</span>
1929
+ <span class="default">
1930
+
1931
+ </span>
1932
+ &mdash; <div class='inline'><p>
1933
+ The target state
1934
+ </p>
1935
+ </div>
1936
+ </li>
1937
+
1938
+ <li>
1939
+ <span class="name">:deep</span>
1940
+ <span class="type">(<tt>Boolean</tt>)</span>
1941
+ <span class="default">
1942
+
1943
+ </span>
1944
+ &mdash; <div class='inline'><p>
1945
+ Whether to enable deep searches for the target state
1946
+ </p>
1947
+ </div>
1948
+ </li>
1949
+
1950
+ <li>
1951
+ <span class="name">:guard</span>
1952
+ <span class="type">(<tt>Boolean</tt>)</span>
1953
+ <span class="default">
1954
+
1955
+ </span>
1956
+ &mdash; <div class='inline'><p>
1957
+ Whether to guard transitions with conditionals
1958
+ </p>
1959
+ </div>
1960
+ </li>
1961
+
1962
+ </ul>
1963
+
1964
+
1965
+ <h3>Returns:</h3>
1966
+ <ul class="return">
1967
+
1968
+ <li>
1969
+
1970
+
1971
+ <span class='type'>(<tt>StateMachine::PathCollection</tt>)</span>
1972
+
1973
+
1974
+
1975
+ &mdash;
1976
+ <div class='inline'><p>
1977
+ The collection of paths
1978
+ </p>
1979
+ </div>
1980
+
1981
+ </li>
1982
+
1983
+ </ul>
1984
+
1985
+ </div><table class="source_code">
1986
+ <tr>
1987
+ <td>
1988
+ <pre class="lines">
1989
+
1990
+
1991
+ 4
1992
+ 5
1993
+ 6
1994
+ 7
1995
+ 8</pre>
1996
+ </td>
1997
+ <td>
1998
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
1999
+
2000
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
2001
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
2002
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
2003
+ <span class='kw'>end</span>
2004
+ <span class='kw'>end</span></pre>
2005
+ </td>
2006
+ </tr>
2007
+ </table>
2008
+ </div>
2009
+
2010
+ <div class="method_details ">
2011
+ <p class="signature " id="state_transitions-instance_method">
2012
+
2013
+ - (<tt>Array&lt;StateMachine::Transition&gt;</tt>) <strong>state_transitions</strong>(requirements = {})
2014
+
2015
+
2016
+
2017
+ </p><div class="docstring">
2018
+ <div class="discussion">
2019
+ <p>
2020
+ Gets the list of transitions that can be made for the current state
2021
+ </p>
2022
+
2023
+
2024
+ </div>
2025
+ </div>
2026
+ <div class="tags">
2027
+ <h3>Parameters:</h3>
2028
+ <ul class="param">
2029
+
2030
+ <li>
2031
+
2032
+ <span class='name'>requirements</span>
2033
+
2034
+
2035
+ <span class='type'>(<tt>Hash</tt>)</span>
2036
+
2037
+
2038
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
2039
+
2040
+
2041
+ &mdash;
2042
+ <div class='inline'><p>
2043
+ The transition requirements to test against
2044
+ </p>
2045
+ </div>
2046
+
2047
+ </li>
2048
+
2049
+ </ul>
2050
+
2051
+
2052
+
2053
+
2054
+ <h3>Options Hash (<tt>requirements</tt>):</h3>
2055
+ <ul class="option">
2056
+
2057
+ <li>
2058
+ <span class="name">:from</span>
2059
+ <span class="type">(<tt>Symbol</tt>)</span>
2060
+ <span class="default">
2061
+
2062
+ &mdash; default:
2063
+ <tt>the current state</tt>
2064
+
2065
+ </span>
2066
+ &mdash; <div class='inline'><p>
2067
+ One or more initial states
2068
+ </p>
2069
+ </div>
2070
+ </li>
2071
+
2072
+ <li>
2073
+ <span class="name">:to</span>
2074
+ <span class="type">(<tt>Symbol</tt>)</span>
2075
+ <span class="default">
2076
+
2077
+ </span>
2078
+ &mdash; <div class='inline'><p>
2079
+ One or more target states
2080
+ </p>
2081
+ </div>
2082
+ </li>
2083
+
2084
+ <li>
2085
+ <span class="name">:on</span>
2086
+ <span class="type">(<tt>Symbol</tt>)</span>
2087
+ <span class="default">
2088
+
2089
+ </span>
2090
+ &mdash; <div class='inline'><p>
2091
+ One or more events that fire the transition
2092
+ </p>
2093
+ </div>
2094
+ </li>
2095
+
2096
+ <li>
2097
+ <span class="name">:guard</span>
2098
+ <span class="type">(<tt>Boolean</tt>)</span>
2099
+ <span class="default">
2100
+
2101
+ </span>
2102
+ &mdash; <div class='inline'><p>
2103
+ Whether to guard transitions with conditionals
2104
+ </p>
2105
+ </div>
2106
+ </li>
2107
+
2108
+ </ul>
2109
+
2110
+
2111
+ <h3>Returns:</h3>
2112
+ <ul class="return">
2113
+
2114
+ <li>
2115
+
2116
+
2117
+ <span class='type'>(<tt>Array&lt;StateMachine::Transition&gt;</tt>)</span>
2118
+
2119
+
2120
+
2121
+ &mdash;
2122
+ <div class='inline'><p>
2123
+ The available transitions
2124
+ </p>
2125
+ </div>
2126
+
2127
+ </li>
2128
+
2129
+ </ul>
2130
+
2131
+ </div><table class="source_code">
2132
+ <tr>
2133
+ <td>
2134
+ <pre class="lines">
2135
+
2136
+
2137
+ 4
2138
+ 5
2139
+ 6
2140
+ 7
2141
+ 8</pre>
2142
+ </td>
2143
+ <td>
2144
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
2145
+
2146
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
2147
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
2148
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
2149
+ <span class='kw'>end</span>
2150
+ <span class='kw'>end</span></pre>
2151
+ </td>
2152
+ </tr>
2153
+ </table>
2154
+ </div>
2155
+
2156
+ <div class="method_details ">
2157
+ <p class="signature " id="stop?-instance_method">
2158
+
2159
+ - (<tt>Boolean</tt>) <strong>stop?</strong>
2160
+
2161
+
2162
+
2163
+ </p><div class="docstring">
2164
+ <div class="discussion">
2165
+ <p>
2166
+ Checks whether :stop is the current state.
2167
+ </p>
2168
+
2169
+
2170
+ </div>
2171
+ </div>
2172
+ <div class="tags">
2173
+
2174
+ <h3>Returns:</h3>
2175
+ <ul class="return">
2176
+
2177
+ <li>
2178
+
2179
+
2180
+ <span class='type'>(<tt>Boolean</tt>)</span>
2181
+
2182
+
2183
+
2184
+ &mdash;
2185
+ <div class='inline'><p>
2186
+ <tt>true</tt> if this is the current state, otherwise <tt>false</tt>
2187
+ </p>
2188
+ </div>
2189
+
2190
+ </li>
2191
+
2192
+ </ul>
2193
+
2194
+ </div><table class="source_code">
2195
+ <tr>
2196
+ <td>
2197
+ <pre class="lines">
2198
+
2199
+
2200
+ 4
2201
+ 5
2202
+ 6
2203
+ 7
2204
+ 8</pre>
2205
+ </td>
2206
+ <td>
2207
+ <pre class="code"><span class="info file"># File 'traffic_light.rb', line 4</span>
2208
+
2209
+ <span class='id identifier rubyid_state_machine'>state_machine</span> <span class='symbol'>:initial</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span> <span class='kw'>do</span>
2210
+ <span class='id identifier rubyid_event'>event</span> <span class='symbol'>:cycle</span> <span class='kw'>do</span>
2211
+ <span class='id identifier rubyid_transition'>transition</span> <span class='symbol'>:stop</span> <span class='op'>=&gt;</span> <span class='symbol'>:proceed</span><span class='comma'>,</span> <span class='symbol'>:proceed</span> <span class='op'>=&gt;</span> <span class='symbol'>:caution</span><span class='comma'>,</span> <span class='symbol'>:caution</span> <span class='op'>=&gt;</span> <span class='symbol'>:stop</span>
2212
+ <span class='kw'>end</span>
2213
+ <span class='kw'>end</span></pre>
2214
+ </td>
2215
+ </tr>
2216
+ </table>
2217
+ </div>
2218
+
2219
+ </div>
2220
+
2221
+ </div>
2222
+
2223
+ <div id="footer">
2224
+ Generated on Fri Feb 17 08:30:35 2012 by
2225
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2226
+ 0.7.5 (ruby-1.9.2).
2227
+ </div>
2228
+
2229
+ </body>
2230
+ </html>