Parent

Class/Module Index [+]

Quicksearch

Nanoc::CodeSnippet

Nanoc::CodeSnippet represent a piece of custom code of a nanoc site.

Attributes

data[R]

A string containing the actual code in this code snippet.

@return [String]

filename[R]

The filename corresponding to this code snippet.

@return [String]

Public Class Methods

new(data, filename, params=nil) click to toggle source

Creates a new code snippet.

@param [String] data The raw source code which will be executed before

compilation

@param [String] filename The filename corresponding to this code snippet

@param [Time, Hash] params Extra parameters. Ignored by nanoc; it is

only included for backwards compatibility.
# File lib/nanoc/base/source_data/code_snippet.rb, line 26
def initialize(data, filename, params=nil)
  @data     = data
  @filename = filename
end

Public Instance Methods

checksum() click to toggle source

@return [String] The checksum for this object. If its contents change,

the checksum will change as well.
# File lib/nanoc/base/source_data/code_snippet.rb, line 51
def checksum
  @data.checksum
end
inspect() click to toggle source
# File lib/nanoc/base/source_data/code_snippet.rb, line 45
def inspect
  "<#{self.class} filename=\"#{self.filename}\">"
end
load() click to toggle source

Loads the code by executing it.

@return [void]

# File lib/nanoc/base/source_data/code_snippet.rb, line 34
def load
  eval(@data, TOPLEVEL_BINDING, @filename)
end
reference() click to toggle source

Returns an object that can be used for uniquely identifying objects.

@return [Object] An unique reference to this object

# File lib/nanoc/base/source_data/code_snippet.rb, line 41
def reference
  [ :code_snippet, filename ]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.