Class: Nanoc::BasicItemRepView

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

Instance Method Summary collapse

Methods inherited from View

#frozen?

Instance Method Details

#==(other) ⇒ Object

See Also:

  • Object#==


22
23
24
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 22

def ==(other)
  other.respond_to?(:item) && other.respond_to?(:name) && item == other.item && name == other.name
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)

See Also:

  • Object#eql?


27
28
29
30
31
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 27

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

#hashObject

See Also:

  • Object#hash


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

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

#inspectObject



76
77
78
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 76

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

#itemNanoc::CompilationItemView

Returns the item that this item rep belongs to.



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

def item
  item_view_class.new(@item_rep.item, @context)
end

#item_view_classObject

This method is abstract.


12
13
14
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 12

def item_view_class
  Nanoc::BasicItemView
end

#nameSymbol

Returns:

  • (Symbol)


39
40
41
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 39

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.



57
58
59
60
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 57

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

#snapshot?(name) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/nanoc/base/views/basic_item_rep_view.rb', line 43

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