Sha256: 35b1c7c8ab77fb7d86a4a33675ccf4eee359d83164018a17cd8ba69225c1286c
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
module Nanoc::Int # Nanoc::Int::CodeSnippet represent a piece of custom code of a Nanoc site. # # @api private class CodeSnippet include Nanoc::Int::ContractsSupport # A string containing the actual code in this code snippet. # # @return [String] attr_reader :data # The filename corresponding to this code snippet. # # @return [String] attr_reader :filename contract String, String => C::Any # 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 def initialize(data, filename) @data = data @filename = filename end contract C::None => nil # Loads the code by executing it. # # @return [void] def load # rubocop:disable Lint/Eval eval(@data, TOPLEVEL_BINDING, @filename) # rubocop:enable Lint/Eval nil end # Returns an object that can be used for uniquely identifying objects. # # @return [Object] An unique reference to this object def reference [:code_snippet, filename] end def inspect "<#{self.class} filename=\"#{filename}\">" end end end
Version data entries
6 entries across 6 versions & 1 rubygems