Parent

Methods

Class/Module Index [+]

Quicksearch

Nanoc3::CodeSnippet

Nanoc3::CodeSnippet represent a piece of custom code of a nanoc site. It contains the textual source code as well as a mtime, which is used to speed up site compilation.

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]

mtime[R]

The time where this code snippet was last modified.

@return [Time]

site[RW]

The {Nanoc3::Site} this code snippet belongs to.

@return [Nanoc3::Site]

Public Class Methods

new(data, filename, mtime=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] mtime The time when the code was last modified (can be nil)

# File lib/nanoc3/base/code_snippet.rb, line 38
def initialize(data, filename, mtime=nil)
  @data     = data
  @filename = filename
  @mtime    = mtime
end

Public Instance Methods

load() click to toggle source

Loads the code by executing it.

@return [void]

# File lib/nanoc3/base/code_snippet.rb, line 47
def load
  eval(@data, TOPLEVEL_BINDING, @filename)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.