Class: Perkins::Build::Shell::Group

Inherits:
Node show all
Includes:
Dsl
Defined in:
lib/perkins/build/shell/node.rb

Direct Known Subclasses

Block, Script

Instance Attribute Summary collapse

Attributes inherited from Node

#code, #level, #options

Instance Method Summary collapse

Methods included from Dsl

#cd, #cmd, #echo, #elif, #else, #export, #file, #fold, #if, #newline, #raw, #script, #set

Methods inherited from Node

#escape, #name

Constructor Details

#initialize(*args) {|_self| ... } ⇒ Group

Returns a new instance of Group.

Yields:

  • (_self)

Yield Parameters:



55
56
57
58
59
60
61
# File 'lib/perkins/build/shell/node.rb', line 55

def initialize(*args, &block)
  @options = args.last.is_a?(Hash) ? args.pop : {}
  @level = options.delete(:level) || 0
  @nodes = []
  args.map { |node| cmd(node, options) }
  yield(self) if block_given?
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



53
54
55
# File 'lib/perkins/build/shell/node.rb', line 53

def nodes
  @nodes
end

Instance Method Details

#to_sObject



63
64
65
# File 'lib/perkins/build/shell/node.rb', line 63

def to_s
  nodes.map(&:to_s).join("\n").indent(level)
end