class Nanoc::ItemRepView

Public Class Methods

new(item_rep, context) click to toggle source

@api private

Calls superclass method Nanoc::View.new
# File lib/nanoc/base/views/item_rep_view.rb, line 4
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/base/views/item_rep_view.rb, line 15
def ==(other)
  other.respond_to?(:item) && other.respond_to?(:name) && item == other.item && name == other.name
end
Also aliased as: eql?
binary?() click to toggle source

@api private

# File lib/nanoc/base/views/item_rep_view.rb, line 77
def binary?
  @item_rep.binary?
end
compiled_content(snapshot: nil) click to toggle source

Returns the compiled content.

@param [String] snapshot The name of the snapshot from which to

fetch the compiled content. By default, the returned compiled content
will be the content compiled right before the first layout call (if
any).

@return [String] The content at the given snapshot.

# File lib/nanoc/base/views/item_rep_view.rb, line 38
def compiled_content(snapshot: nil)
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
  Nanoc::Int::NotificationCenter.post(:visit_ended,   unwrap.item)

  @item_rep.compiled_content(snapshot: snapshot)
end
eql?(other)
Alias for: ==
hash() click to toggle source

@see Object#hash

# File lib/nanoc/base/views/item_rep_view.rb, line 21
def hash
  self.class.hash ^ item.identifier.hash ^ name.hash
end
item() click to toggle source

Returns the item that this item rep belongs to.

@return [Nanoc::ItemWithRepsView]

# File lib/nanoc/base/views/item_rep_view.rb, line 64
def item
  Nanoc::ItemWithRepsView.new(@item_rep.item, @context)
end
name() click to toggle source

@return [Symbol]

# File lib/nanoc/base/views/item_rep_view.rb, line 26
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/base/views/item_rep_view.rb, line 54
def path(snapshot: :last)
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
  Nanoc::Int::NotificationCenter.post(:visit_ended,   unwrap.item)

  @item_rep.path(snapshot: snapshot)
end
raw_path(snapshot: :last) click to toggle source

@api private

# File lib/nanoc/base/views/item_rep_view.rb, line 69
def raw_path(snapshot: :last)
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
  Nanoc::Int::NotificationCenter.post(:visit_ended,   unwrap.item)

  @item_rep.raw_path(snapshot: snapshot)
end
unwrap() click to toggle source

@api private

# File lib/nanoc/base/views/item_rep_view.rb, line 10
def unwrap
  @item_rep
end