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 ⇒ Array(String)
The path of this derived base class.
-
.to_s ⇒ String
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 ⇒ Array(String)
The path for this derived base class.
-
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
-
#recipes ⇒ Enumerable
Recipes defined in this scope.
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
26 27 28 |
# File 'lib/bake/base.rb', line 26 def context @context end |
Class Method Details
.derive(path = []) ⇒ Object
Generate a base class for the specified path.
29 30 31 32 33 34 35 |
# File 'lib/bake/base.rb', line 29 def self.derive(path = []) klass = Class.new(self) klass.const_set(:PATH, path) return klass end |
.inspect ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/bake/base.rb', line 47 def self.inspect if path = self.path "Bake::Base<#{path.join(':')}>" else super end end |
.path ⇒ Array(String)
The path of this derived base class.
57 58 59 60 61 |
# File 'lib/bake/base.rb', line 57 def self.path self.const_get(:PATH) rescue nil end |
.to_s ⇒ String
Format the class as a command.
39 40 41 42 43 44 45 |
# File 'lib/bake/base.rb', line 39 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.
71 72 73 |
# File 'lib/bake/base.rb', line 71 def call(*arguments) self.context.call(*arguments) end |
#path ⇒ Array(String)
The path for this derived base class.
65 66 67 |
# File 'lib/bake/base.rb', line 65 def path self.class.path end |
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
93 94 95 |
# File 'lib/bake/base.rb', line 93 def recipe_for(name) Recipe.new(self, name) end |
#recipes ⇒ Enumerable
Recipes defined in this scope.
80 81 82 83 84 85 86 87 88 |
# File 'lib/bake/base.rb', line 80 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 |