Sha256: af67e8979ecf7822354c423959a74004383a79140c80c68ee98ea5a892c19d6c
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
# encoding: utf-8 module Nanoc3 # Represents a layout in a nanoc site. It has content, attributes, an # identifier and a modification time (to speed up compilation). class Layout # @return [Nanoc3::Site] The site this layout belongs to attr_accessor :site # @return [String] The raw content of this layout attr_reader :raw_content # @return [Hash] This layout's attributes attr_reader :attributes # @return [String] This layout's identifier, starting and ending with a # slash attr_accessor :identifier # @return [Time] The time when this layout was last modified attr_reader :mtime # Creates a new layout. # # @param [String] content The raw content of this layout. # # @param [Hash] attributes A hash containing this layout's attributes. # # @param [String] identifier This layout's identifier. # # @param [Time, nil] mtime The time when this layout was last modified. def initialize(raw_content, attributes, identifier, mtime=nil) @raw_content = raw_content @attributes = attributes.symbolize_keys @identifier = identifier.cleaned_identifier @mtime = mtime end # Requests the attribute with the given key. # # @param [Symbol] key The name of the attribute to fetch. # # @return [Object] The value of the requested attribute. def [](key) @attributes[key] end def inspect "<#{self.class}:0x#{self.object_id.to_s(16)} identifier=#{self.identifier}>" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc3-3.1.0a2 | lib/nanoc3/base/layout.rb |
nanoc3-3.1.0a1 | lib/nanoc3/base/layout.rb |