Class: Kutils::DSLBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/dsl_builder.rb

Overview

DSLBuilder provides a simple DSL for configuration or scripting.

Instance Method Summary collapse

Constructor Details

#initialize { ... } ⇒ DSLBuilder

Returns a new instance of DSLBuilder.

Yields:

  • DSL block



11
12
13
# File 'lib/utils/dsl_builder.rb', line 11

def initialize(&block)
  instance_eval(&block) if block_given?
end

Instance Method Details

#task(name) { ... } ⇒ Object

Define a task with a name and block

Parameters:

  • name (String)

Yields:

  • Block to execute for the task



18
19
20
21
# File 'lib/utils/dsl_builder.rb', line 18

def task(name, &block)
  puts "Define task: #{name}"
  block.call if block_given?
end