Class: DirectoryTemplate::ProcessData
- Defined in:
- lib/directory_template/process_data.rb
Overview
ProcessData is the value that gets passed to processors. The processor must mutate it.
Instance Attribute Summary collapse
-
#content ⇒ Object
The file-content, as it is in the current stage of processing (nil for directories).
-
#content_variables ⇒ Object
readonly
Variables to be used for filecontent preprocessing.
-
#directory ⇒ Object
readonly
The directory, as it is in the current stage of processing.
-
#directory_template ⇒ Object
readonly
A reference to the DirectoryTemplate of which this file/directory is part of.
-
#filename ⇒ Object
readonly
The filename, as it is in the current stage of processing.
-
#path ⇒ Object
The path as it is in the current stage of processing.
-
#path_variables ⇒ Object
readonly
Variables to be used for path preprocessing.
-
#suffix ⇒ Object
readonly
The suffix, as it is in the current stage of processing.
-
#variables ⇒ Object
readonly
Variables to be used for both, path- and filecontent preprocessing.
Instance Method Summary collapse
-
#===(processor) ⇒ Object
Whether the processor is suitable for the given ProcessData.
-
#chomp_suffix! ⇒ Object
Removes the current suffix.
-
#directory? ⇒ Boolean
Whether the item is a directory.
-
#file? ⇒ Boolean
Whether the item is a file.
-
#initialize(directory_template, path, content, env) ⇒ ProcessData
constructor
A content of nil means this is a directory.
Constructor Details
#initialize(directory_template, path, content, env) ⇒ ProcessData
A content of nil means this is a directory
44 45 46 47 48 49 50 51 |
# File 'lib/directory_template/process_data.rb', line 44 def initialize(directory_template, path, content, env) @directory_template = directory_template @content = content @variables = env[:variables] || {} @path_variables = @variables.merge(env[:path_variables] || {}) @content_variables = @variables.merge(env[:content_variables] || {}) self.path = path end |
Instance Attribute Details
#content ⇒ Object
The file-content, as it is in the current stage of processing (nil for directories).
23 24 25 |
# File 'lib/directory_template/process_data.rb', line 23 def content @content end |
#content_variables ⇒ Object (readonly)
Variables to be used for filecontent preprocessing
29 30 31 |
# File 'lib/directory_template/process_data.rb', line 29 def content_variables @content_variables end |
#directory ⇒ Object (readonly)
The directory, as it is in the current stage of processing.
17 18 19 |
# File 'lib/directory_template/process_data.rb', line 17 def directory @directory end |
#directory_template ⇒ Object (readonly)
A reference to the DirectoryTemplate of which this file/directory is part of
8 9 10 |
# File 'lib/directory_template/process_data.rb', line 8 def directory_template @directory_template end |
#filename ⇒ Object (readonly)
The filename, as it is in the current stage of processing.
14 15 16 |
# File 'lib/directory_template/process_data.rb', line 14 def filename @filename end |
#path ⇒ Object
The path as it is in the current stage of processing.
11 12 13 |
# File 'lib/directory_template/process_data.rb', line 11 def path @path end |
#path_variables ⇒ Object (readonly)
Variables to be used for path preprocessing
26 27 28 |
# File 'lib/directory_template/process_data.rb', line 26 def path_variables @path_variables end |
#suffix ⇒ Object (readonly)
The suffix, as it is in the current stage of processing.
20 21 22 |
# File 'lib/directory_template/process_data.rb', line 20 def suffix @suffix end |
#variables ⇒ Object (readonly)
Variables to be used for both, path- and filecontent preprocessing
32 33 34 |
# File 'lib/directory_template/process_data.rb', line 32 def variables @variables end |
Instance Method Details
#===(processor) ⇒ Object
Whether the processor is suitable for the given ProcessData. Simply delegates the job to the Processor.
57 58 59 |
# File 'lib/directory_template/process_data.rb', line 57 def ===(processor) processor === self end |
#chomp_suffix! ⇒ Object
Removes the current suffix. E.g. “foo/bar.baz.quuz” would be “foo/bar.baz” after the operation.
90 91 92 |
# File 'lib/directory_template/process_data.rb', line 90 def chomp_suffix! self.path = @path.chomp(@suffix) end |
#directory? ⇒ Boolean
Returns Whether the item is a directory. The alternative is, that it is a file.
73 74 75 |
# File 'lib/directory_template/process_data.rb', line 73 def directory? !@content end |
#file? ⇒ Boolean
Returns Whether the item is a file. The alternative is, that it is a directory.
65 66 67 |
# File 'lib/directory_template/process_data.rb', line 65 def file? !!@content end |