Class: Tryruby::Tutorial
- Inherits:
-
Object
- Object
- Tryruby::Tutorial
- Extended by:
- Enumerable
- Defined in:
- lib/tryruby/tutorial.rb
Overview
Base module for level DSL
Direct Known Subclasses
Defined Under Namespace
Modules: Commands
Class Method Summary collapse
Instance Method Summary collapse
- #[](i) ⇒ Object
- #commands ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ Tutorial
constructor
A new instance of Tutorial.
- #length ⇒ Object
Constructor Details
#initialize ⇒ Tutorial
Returns a new instance of Tutorial.
12 13 14 15 16 17 18 19 |
# File 'lib/tryruby/tutorial.rb', line 12 def initialize @levels = [] self.class.each do |block| builder = LevelBuilder.new builder.instance_eval(&block) @levels << builder.level end end |
Class Method Details
.each(&block) ⇒ Object
37 38 39 |
# File 'lib/tryruby/tutorial.rb', line 37 def self.each(&block) levels.each(&block) end |
.level(&block) ⇒ Object
41 42 43 |
# File 'lib/tryruby/tutorial.rb', line 41 def self.level(&block) levels << block end |
.levels ⇒ Object
45 46 47 |
# File 'lib/tryruby/tutorial.rb', line 45 def self.levels @levels ||= [] end |
Instance Method Details
#[](i) ⇒ Object
21 22 23 |
# File 'lib/tryruby/tutorial.rb', line 21 def [](i) @levels[i] end |
#commands ⇒ Object
33 34 35 |
# File 'lib/tryruby/tutorial.rb', line 33 def commands self.class::Commands end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/tryruby/tutorial.rb', line 25 def each(&block) @levels.each(&block) end |
#length ⇒ Object
29 30 31 |
# File 'lib/tryruby/tutorial.rb', line 29 def length @levels.length end |