Class: RgGen::CodeUtility::SourceFile
- Inherits:
-
Object
- Object
- RgGen::CodeUtility::SourceFile
show all
- Includes:
- RgGen::CodeUtility
- Defined in:
- lib/rggen/core_components/code_utility/source_file.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#create_blank_code
Constructor Details
#initialize(path) {|_self| ... } ⇒ SourceFile
Returns a new instance of SourceFile.
13
14
15
16
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 13
def initialize(path)
@path = path
yield(self) if block_given?
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
18
19
20
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 18
def path
@path
end
|
Instance Method Details
#body(&block) ⇒ Object
34
35
36
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 34
def body(&block)
@body_block ||= block
end
|
20
21
22
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 20
def (&block)
@header_block ||= block
end
|
#include_file(file) ⇒ Object
30
31
32
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 30
def include_file(file)
include_files << file
end
|
#include_guard(prefix = nil, suffix = prefix, &block) ⇒ Object
24
25
26
27
28
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 24
def include_guard(prefix = nil, suffix = prefix, &block)
@guard_macro ||= (
block || method(:default_guard_macro)
).call(prefix, suffix)
end
|
#to_code ⇒ Object
38
39
40
41
42
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 38
def to_code
code_block do |c|
blocks.each { |b| generate_code(c, b) }
end
end
|
#to_s ⇒ Object
44
45
46
|
# File 'lib/rggen/core_components/code_utility/source_file.rb', line 44
def to_s
to_code.to_s
end
|