Class: DevScripts::Support::Block
- Inherits:
-
String
- Object
- String
- DevScripts::Support::Block
- Defined in:
- lib/dev_scripts/support/block.rb
Instance Method Summary collapse
-
#initialize(args_node, block_node) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(args_node, block_node) ⇒ Block
Returns a new instance of Block.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dev_scripts/support/block.rb', line 4 def initialize(args_node, block_node) @block_node = block_node self << 'do' if args_node.children.size > 0 self << args_node.children.each_with_object(' |').with_index do |(arg, string), index| string << arg.children.first.to_s string << ', ' if index < args_node.children.size - 1 string << '|' if index == args_node.children.size - 1 end end self << "\n" self << ' ' + body self << "\n" self << 'end' end |