Class: Nanoc::CodeSnippet
- Inherits:
-
Object
- Object
- Nanoc::CodeSnippet
- Defined in:
- lib/nanoc/base/source_data/code_snippet.rb
Overview
Nanoc::CodeSnippet represent a piece of custom code of a nanoc site.
Instance Attribute Summary (collapse)
-
- (String) data
readonly
A string containing the actual code in this code snippet.
-
- (String) filename
readonly
The filename corresponding to this code snippet.
Instance Method Summary (collapse)
-
- (String) checksum
The checksum for this object.
-
- (CodeSnippet) initialize(data, filename, _params = nil)
constructor
Creates a new code snippet.
-
- (Object) inspect
-
- (void) load
Loads the code by executing it.
-
- (Object) reference
Returns an object that can be used for uniquely identifying objects.
Constructor Details
- (CodeSnippet) initialize(data, filename, _params = nil)
Creates a new code snippet.
25 26 27 28 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 25 def initialize(data, filename, _params = nil) @data = data @filename = filename end |
Instance Attribute Details
- (String) data (readonly)
A string containing the actual code in this code snippet.
9 10 11 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 9 def data @data end |
- (String) filename (readonly)
The filename corresponding to this code snippet.
14 15 16 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 14 def filename @filename end |
Instance Method Details
- (String) checksum
Returns The checksum for this object. If its contents change, the checksum will change as well.
50 51 52 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 50 def checksum Nanoc::Checksummer.calc(self) end |
- (Object) inspect
44 45 46 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 44 def inspect "<#{self.class} filename=\"#{filename}\">" end |
- (void) load
This method returns an undefined value.
Loads the code by executing it.
33 34 35 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 33 def load eval(@data, TOPLEVEL_BINDING, @filename) end |
- (Object) reference
Returns an object that can be used for uniquely identifying objects.
40 41 42 |
# File 'lib/nanoc/base/source_data/code_snippet.rb', line 40 def reference [:code_snippet, filename] end |