class Nanoc::Int::CodeSnippet

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

@api private

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) 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

# File lib/nanoc/base/entities/code_snippet.rb, line 22
def initialize(data, filename)
  @data     = data
  @filename = filename
end

Public Instance Methods

inspect() click to toggle source
# File lib/nanoc/base/entities/code_snippet.rb, line 41
def inspect
  "<#{self.class} filename=\"#{filename}\">"
end
load() click to toggle source

Loads the code by executing it.

@return [void]

# File lib/nanoc/base/entities/code_snippet.rb, line 30
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/entities/code_snippet.rb, line 37
def reference
  [:code_snippet, filename]
end