Class: Nanoc::ItemRepView

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

Direct Known Subclasses

PostCompileItemRepView

Instance Method Summary collapse

Methods inherited from View

#frozen?

Instance Method Details

#==(other) ⇒ Object

See Also:

  • Object#==


17
18
19
# File 'lib/nanoc/base/views/item_rep_view.rb', line 17

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.



46
47
48
49
# File 'lib/nanoc/base/views/item_rep_view.rb', line 46

def compiled_content(snapshot: nil)
  @context.dependency_tracker.bounce(unwrap.item, compiled_content: true)
  @context.snapshot_repo.compiled_content(rep: unwrap, snapshot: snapshot)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Object#eql?


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

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

#hashObject

See Also:

  • Object#hash


29
30
31
# File 'lib/nanoc/base/views/item_rep_view.rb', line 29

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

#inspectObject



97
98
99
# File 'lib/nanoc/base/views/item_rep_view.rb', line 97

def inspect
  "<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
end

#itemNanoc::ItemWithRepsView

Returns the item that this item rep belongs to.



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

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

#nameSymbol

Returns:

  • (Symbol)


34
35
36
# File 'lib/nanoc/base/views/item_rep_view.rb', line 34

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.



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

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

#snapshot?(name) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/nanoc/base/views/item_rep_view.rb', line 51

def snapshot?(name)
  @context.dependency_tracker.bounce(unwrap.item, compiled_content: true)
  @item_rep.snapshot?(name)
end