class Nanoc::Core::BasicItemRepView

Public Class Methods

new(item_rep, context) click to toggle source

@api private

Calls superclass method Nanoc::Core::View::new
# File lib/nanoc/core/basic_item_rep_view.rb, line 7
def initialize(item_rep, context)
  super(context)
  @item_rep = item_rep
end

Public Instance Methods

==(other) click to toggle source

@see Object#==

# File lib/nanoc/core/basic_item_rep_view.rb, line 23
def ==(other)
  other.respond_to?(:item) && other.respond_to?(:name) && item == other.item && name == other.name
end
_unwrap() click to toggle source

@api private

# File lib/nanoc/core/basic_item_rep_view.rb, line 18
def _unwrap
  @item_rep
end
binary?() click to toggle source

@api private

# File lib/nanoc/core/basic_item_rep_view.rb, line 71
def binary?
  snapshot_def = _unwrap.snapshot_defs.find { |sd| sd.name == :last }
  raise Nanoc::Core::Errors::NoSuchSnapshot.new(_unwrap, :last) if snapshot_def.nil?

  snapshot_def.binary?
end
eql?(other) click to toggle source

@see Object#eql?

# File lib/nanoc/core/basic_item_rep_view.rb, line 28
def eql?(other)
  other.is_a?(self.class) &&
    item.eql?(other.item) &&
    name.eql?(other.name)
end
hash() click to toggle source

@see Object#hash

# File lib/nanoc/core/basic_item_rep_view.rb, line 35
def hash
  self.class.hash ^ item.identifier.hash ^ name.hash
end
inspect() click to toggle source
# File lib/nanoc/core/basic_item_rep_view.rb, line 78
def inspect
  "<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
end
item() click to toggle source

Returns the item that this item rep belongs to.

@return [Nanoc::Core::CompilationItemView]

# File lib/nanoc/core/basic_item_rep_view.rb, line 66
def item
  item_view_class.new(@item_rep.item, @context)
end
item_view_class() click to toggle source

@abstract

# File lib/nanoc/core/basic_item_rep_view.rb, line 13
def item_view_class
  Nanoc::Core::BasicItemView
end
name() click to toggle source

@return [Symbol]

# File lib/nanoc/core/basic_item_rep_view.rb, line 40
def name
  @item_rep.name
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.

@param [Symbol] snapshot The snapshot for which the path should be

returned.

@return [String] The item rep’s path.

# File lib/nanoc/core/basic_item_rep_view.rb, line 58
def path(snapshot: :last)
  @context.dependency_tracker.bounce(_unwrap.item, path: true)
  @item_rep.path(snapshot: snapshot)
end
snapshot?(name) click to toggle source
# File lib/nanoc/core/basic_item_rep_view.rb, line 44
def snapshot?(name)
  @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
  @item_rep.snapshot?(name)
end