class Nanoc::Core::ItemRep

Attributes

compiled[RW]
compiled?[RW]
item[R]
modified[RW]
modified?[RW]
name[R]
paths[R]
raw_paths[R]
snapshot_defs[RW]

Public Class Methods

new(item, name) click to toggle source
# File lib/nanoc/core/item_rep.rb, line 32
def initialize(item, name)
  # Set primary attributes
  @item   = item
  @name   = name

  # Set default attributes
  @raw_paths  = {}
  @paths      = {}
  @snapshot_defs = []

  # Reset flags
  @compiled = false
  @modified = false
end

Public Instance Methods

inspect() click to toggle source
# File lib/nanoc/core/item_rep.rb, line 87
def inspect
  "<#{self.class} name=\"#{name}\" raw_path=\"#{raw_path}\" item.identifier=\"#{item.identifier}\">"
end
path(snapshot: :last) click to toggle source

Returns the item rep’s path, as used when being linked to. It starts with a slash and it is relative to the output directory. It does not include the path to the output directory. It will not include the filename if the filename is an index filename.

# File lib/nanoc/core/item_rep.rb, line 74
def path(snapshot: :last)
  @paths.fetch(snapshot, []).first
end
paths=(val) click to toggle source
# File lib/nanoc/core/item_rep.rb, line 53
def paths=(val)
  @paths = val
end
raw_path(snapshot: :last) click to toggle source

Returns the item rep’s raw path. It includes the path to the output directory and the full filename.

# File lib/nanoc/core/item_rep.rb, line 65
def raw_path(snapshot: :last)
  @raw_paths.fetch(snapshot, []).first
end
raw_paths=(val) click to toggle source
# File lib/nanoc/core/item_rep.rb, line 48
def raw_paths=(val)
  @raw_paths = val
end
reference() click to toggle source

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

# File lib/nanoc/core/item_rep.rb, line 79
def reference
  "item_rep:#{item.identifier}:#{name}"
end
snapshot?(name) click to toggle source
# File lib/nanoc/core/item_rep.rb, line 58
def snapshot?(name)
  snapshot_defs.any? { |sd| sd.name == name }
end
to_s() click to toggle source
# File lib/nanoc/core/item_rep.rb, line 83
def to_s
  "#{item.identifier} (rep name #{name.inspect})"
end