Class: Nanoc::ItemRepView

Inherits:
View
  • Object
show all
Defined in:
lib/nanoc/base/views/item_rep_view.rb

Instance Method Summary collapse

Methods inherited from View

#frozen?

Instance Method Details

#==(other) ⇒ Object

See Also:

  • Object#==


15
16
17
# 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

#compiled_content(snapshot: nil) ⇒ String

Returns the compiled content.

Parameters:

  • snapshot (String)

    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).

Returns:

  • (String)

    The content at the given snapshot.



44
45
46
47
# File 'lib/nanoc/base/views/item_rep_view.rb', line 44

def compiled_content(snapshot: nil)
  @context.dependency_tracker.bounce(unwrap.item)
  @item_rep.compiled_content(snapshot: snapshot)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Object#eql?


20
21
22
23
24
# File 'lib/nanoc/base/views/item_rep_view.rb', line 20

def eql?(other)
  other.is_a?(self.class) &&
    item.eql?(other.item) &&
    name.eql?(other.name)
end

#hashObject

See Also:

  • Object#hash


27
28
29
# File 'lib/nanoc/base/views/item_rep_view.rb', line 27

def hash
  self.class.hash ^ item.identifier.hash ^ name.hash
end

#itemNanoc::ItemWithRepsView

Returns the item that this item rep belongs to.



66
67
68
# File 'lib/nanoc/base/views/item_rep_view.rb', line 66

def item
  Nanoc::ItemWithRepsView.new(@item_rep.item, @context)
end

#nameSymbol

Returns:

  • (Symbol)


32
33
34
# File 'lib/nanoc/base/views/item_rep_view.rb', line 32

def name
  @item_rep.name
end

#path(snapshot: :last) ⇒ String

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.

Parameters:

  • snapshot (Symbol)

    The snapshot for which the path should be returned.

Returns:

  • (String)

    The item rep’s path.



58
59
60
61
# File 'lib/nanoc/base/views/item_rep_view.rb', line 58

def path(snapshot: :last)
  @context.dependency_tracker.bounce(unwrap.item)
  @item_rep.path(snapshot: snapshot)
end