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

#_context, #frozen?

Constructor Details

#initialize(item_rep, context) ⇒ ItemRepView

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ItemRepView.



4
5
6
7
# File 'lib/nanoc/base/views/item_rep_view.rb', line 4

def initialize(item_rep, context)
  super(context)
  @item_rep = item_rep
end

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

#binary?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


77
78
79
# File 'lib/nanoc/base/views/item_rep_view.rb', line 77

def binary?
  @item_rep.binary?
end

#compiled_content(snapshot: nil) ⇒ String

Returns the compiled content.

Parameters:

  • snapshot (String) (defaults to: nil)

    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

#inspectObject



81
82
83
# File 'lib/nanoc/base/views/item_rep_view.rb', line 81

def inspect
  "<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
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) (defaults to: :last)

    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

#raw_path(snapshot: :last) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



71
72
73
74
# File 'lib/nanoc/base/views/item_rep_view.rb', line 71

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

#unwrapObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/nanoc/base/views/item_rep_view.rb', line 10

def unwrap
  @item_rep
end