Class: Bake::Base
- Inherits:
-
Struct
- Object
- Struct
- Bake::Base
- Defined in:
- lib/bake/base.rb
Overview
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
Class Method Summary collapse
-
.derive(path = []) ⇒ Object
Generate a base class for the specified path.
- .inspect ⇒ Object
-
.path ⇒ Object
The path of this derived base class.
-
.to_s ⇒ Object
Format the class as a command.
Instance Method Summary collapse
-
#call(*arguments) ⇒ Object
Proxy a method call using command line arguments through to the Context instance.
-
#path ⇒ Object
The path for this derived base class.
-
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
-
#recipes ⇒ Object
Recipes defined in this scope.
- #to_s ⇒ Object
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
11 12 13 |
# File 'lib/bake/base.rb', line 11 def context @context end |
Class Method Details
.derive(path = []) ⇒ Object
Generate a base class for the specified path.
14 15 16 17 18 19 20 |
# File 'lib/bake/base.rb', line 14 def self.derive(path = []) klass = Class.new(self) klass.const_set(:PATH, path) return klass end |
.inspect ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/bake/base.rb', line 32 def self.inspect if path = self.path "Bake::Base<#{path.join(':')}>" else super end end |
.path ⇒ Object
The path of this derived base class.
42 43 44 45 46 |
# File 'lib/bake/base.rb', line 42 def self.path self.const_get(:PATH) rescue nil end |
.to_s ⇒ Object
Format the class as a command.
24 25 26 27 28 29 30 |
# File 'lib/bake/base.rb', line 24 def self.to_s if path = self.path path.join(':') else super end end |
Instance Method Details
#call(*arguments) ⇒ Object
Proxy a method call using command line arguments through to the Context instance.
56 57 58 |
# File 'lib/bake/base.rb', line 56 def call(*arguments) self.context.call(*arguments) end |
#path ⇒ Object
The path for this derived base class.
50 51 52 |
# File 'lib/bake/base.rb', line 50 def path self.class.path end |
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
78 79 80 |
# File 'lib/bake/base.rb', line 78 def recipe_for(name) Recipe.new(self, name) end |
#recipes ⇒ Object
Recipes defined in this scope.
65 66 67 68 69 70 71 72 73 |
# File 'lib/bake/base.rb', line 65 def recipes return to_enum(:recipes) unless block_given? names = self.public_methods - Base.public_instance_methods names.each do |name| yield recipe_for(name) end end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/bake/base.rb', line 82 def to_s "\#<#{self.class}>" end |