Class: Perkins::Build::Shell::Conditional

Inherits:
Block show all
Defined in:
lib/perkins/build/shell/node.rb

Direct Known Subclasses

Elif, If

Instance Attribute Summary

Attributes inherited from Block

#close, #open

Attributes inherited from Group

#nodes

Attributes inherited from Node

#code, #level, #options

Instance Method Summary collapse

Methods inherited from Block

#cmd, #raw, #script, #to_s

Methods inherited from Group

#to_s

Methods included from Dsl

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

Methods inherited from Node

#escape, #name, #to_s

Constructor Details

#initialize(condition, *args, &block) ⇒ Conditional

Returns a new instance of Conditional.



95
96
97
98
99
100
101
102
# File 'lib/perkins/build/shell/node.rb', line 95

def initialize(condition, *args, &block)
  args.unshift(args.last.delete(:then)) if args.last.is_a?(Hash) && args.last[:then]
  unless args.last.delete(:raw_condition)
    condition = "[[ #{condition} ]]"
  end
  super(*args, &block)
  @open = Node.new("#{name} #{condition}; then", options)
end