Class: RgGen::Core::Utility::CodeUtility::SourceFile
Instance Attribute Summary collapse
Instance Method Summary
collapse
array_name, code_block, colon, comma, #create_blank_code, indent, loop_index, newline, nl, semicolon, space, string, wrap
Constructor Details
#initialize(file_path) ⇒ SourceFile
Returns a new instance of SourceFile.
19
20
21
22
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 19
def initialize(file_path)
@file_path = file_path
block_given? && yield(self)
end
|
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
24
25
26
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 24
def file_path
@file_path
end
|
Instance Method Details
#body(&block) ⇒ Object
57
58
59
60
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 57
def body(&block)
@bodies ||= []
@bodies << block
end
|
26
27
28
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 26
def (&block)
@file_header = -> { block.call(@file_path) }
end
|
#include_file(file) ⇒ Object
44
45
46
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 44
def include_file(file)
include_files([file])
end
|
#include_files(files) ⇒ Object
39
40
41
42
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 39
def include_files(files)
@include_files ||= []
@include_files.concat(Array(files))
end
|
#include_guard ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 30
def include_guard
@guard_macro =
if block_given?
yield(default_guard_macro)
else
default_guard_macro
end
end
|
#macro_definition(macro) ⇒ Object
53
54
55
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 53
def macro_definition(macro)
macro_definitions([macro])
end
|
#macro_definitions(macros) ⇒ Object
48
49
50
51
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 48
def macro_definitions(macros)
@macro_definitions ||= []
@macro_definitions.concat(Array(macros))
end
|
62
63
64
65
66
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 62
def to_code
CodeBlock.new do |code|
code_blocks.each { |block| execute_code_block(code, block, true) }
end
end
|
68
69
70
|
# File 'lib/rggen/core/utility/code_utility/source_file.rb', line 68
def to_s
to_code.to_s
end
|