Class: EverydayThorUtil::BuilderBuildItems::BuilderCommand
- Inherits:
-
Object
- Object
- EverydayThorUtil::BuilderBuildItems::BuilderCommand
- Defined in:
- lib/everyday_thor_util/builder.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, obj) ⇒ Object
- #aliases ⇒ Object
- #body ⇒ Object
- #commands ⇒ Object
- #define(&block) ⇒ Object
- #flags ⇒ Object
- #helpers ⇒ Object
-
#initialize(parent = nil, options = {}, &block) ⇒ BuilderCommand
constructor
A new instance of BuilderCommand.
- #leaf? ⇒ Boolean
- #options ⇒ Object
- #parent ⇒ Object
Constructor Details
#initialize(parent = nil, options = {}, &block) ⇒ BuilderCommand
Returns a new instance of BuilderCommand.
7 8 9 10 11 12 |
# File 'lib/everyday_thor_util/builder.rb', line 7 def initialize(parent = nil, = {}, &block) @aliases = .delete(:aliases) if .has_key?(:aliases) && !parent.nil? @parent = parent @options = @body = block end |
Instance Method Details
#[](name) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/everyday_thor_util/builder.rb', line 50 def [](name) if self.commands.has_key?(name) self.commands[name] elsif self.helpers.has_key?(name) self.helpers[name] elsif self.flags.has_key?(name) self.flags[name] else nil end end |
#[]=(name, obj) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/everyday_thor_util/builder.rb', line 62 def []=(name, obj) if obj.is_a?(Hash) self.flags[name] = obj elsif obj.is_a?(BuilderCommand) self.commands[name] = obj elsif obj.is_a?(Proc) self.helpers[name] = obj end end |
#aliases ⇒ Object
30 31 32 |
# File 'lib/everyday_thor_util/builder.rb', line 30 def aliases @aliases ||= [] end |
#body ⇒ Object
18 19 20 |
# File 'lib/everyday_thor_util/builder.rb', line 18 def body @body end |
#commands ⇒ Object
34 35 36 |
# File 'lib/everyday_thor_util/builder.rb', line 34 def commands @commands ||= EverydayThorUtil::BuilderBuildLists::BuilderCommands.new(self) end |
#define(&block) ⇒ Object
26 27 28 |
# File 'lib/everyday_thor_util/builder.rb', line 26 def define(&block) block.call(self.commands, self.flags, self.helpers) end |
#flags ⇒ Object
38 39 40 |
# File 'lib/everyday_thor_util/builder.rb', line 38 def flags @flags ||= EverydayThorUtil::BuilderBuildLists::BuilderFlags.new(self) end |
#helpers ⇒ Object
42 43 44 |
# File 'lib/everyday_thor_util/builder.rb', line 42 def helpers @helpers ||= EverydayThorUtil::BuilderBuildLists::BuilderHelpers.new(self) end |
#leaf? ⇒ Boolean
46 47 48 |
# File 'lib/everyday_thor_util/builder.rb', line 46 def leaf? self.commands.commands.empty? && self.helpers.helpers.empty? end |
#options ⇒ Object
22 23 24 |
# File 'lib/everyday_thor_util/builder.rb', line 22 def @options end |
#parent ⇒ Object
14 15 16 |
# File 'lib/everyday_thor_util/builder.rb', line 14 def parent @parent end |