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.
-
#output?(recipe) ⇒ Boolean
If an instance generates output, it should override this method to return
true, otherwise default output handling will be used (essentially the return value of the last recipe). -
#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.
63 64 65 |
# File 'lib/bake/base.rb', line 63 def call(*arguments) self.context.call(*arguments) end |
#output?(recipe) ⇒ Boolean
If an instance generates output, it should override this method to return true, otherwise default output handling will be used (essentially the return value of the last recipe).
51 52 53 |
# File 'lib/bake/base.rb', line 51 def output?(recipe) false end |
#path ⇒ Object
The path for this derived base class.
57 58 59 |
# File 'lib/bake/base.rb', line 57 def path self.class.path end |
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
85 86 87 |
# File 'lib/bake/base.rb', line 85 def recipe_for(name) Recipe.new(self, name) end |
#recipes ⇒ Object
Recipes defined in this scope.
72 73 74 75 76 77 78 79 80 |
# File 'lib/bake/base.rb', line 72 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
89 90 91 |
# File 'lib/bake/base.rb', line 89 def to_s "\#<#{self.class}>" end |