Class: RgGen::Core::Utility::CodeUtility::StructureDefinition

Inherits:
Object
  • Object
show all
Includes:
RgGen::Core::Utility::CodeUtility
Defined in:
lib/rggen/core/utility/code_utility/structure_definition.rb

Instance Method Summary collapse

Methods included from RgGen::Core::Utility::CodeUtility

array_name, code_block, colon, comma, #create_blank_code, indent, loop_index, newline, nl, semicolon, space, string, wrap

Constructor Details

#initializeStructureDefinition

Returns a new instance of StructureDefinition.



10
11
12
# File 'lib/rggen/core/utility/code_utility/structure_definition.rb', line 10

def initialize
  block_given? && yield(self)
end

Instance Method Details

#body(&block) ⇒ Object



14
15
16
17
# File 'lib/rggen/core/utility/code_utility/structure_definition.rb', line 14

def body(&block)
  return unless block_given?
  (@bodies ||= []) << [block, 2]
end

#to_codeObject



19
20
21
22
23
24
25
# File 'lib/rggen/core/utility/code_utility/structure_definition.rb', line 19

def to_code
  CodeBlock.new do |code|
    code_blocks.each do |block, indent_size|
      indent(code, indent_size) { code.eval_block(&block) }
    end
  end
end