Class: Nanoc::Core::BasicItemRepView
- Inherits:
-
View
- Object
- View
- Nanoc::Core::BasicItemRepView
show all
- Defined in:
- lib/nanoc/core/basic_item_rep_view.rb
Instance Method Summary
collapse
Methods inherited from View
#_context, #frozen?
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(item_rep, context) ⇒ BasicItemRepView
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 BasicItemRepView.
7
8
9
10
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 7
def initialize(item_rep, context)
super(context)
@item_rep = item_rep
end
|
Instance Method Details
#==(other) ⇒ Object
23
24
25
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 23
def ==(other)
other.respond_to?(:item) && other.respond_to?(:name) && item == other.item && name == other.name
end
|
#_unwrap ⇒ 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.
18
19
20
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 18
def _unwrap
@item_rep
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.
71
72
73
74
75
76
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 71
def binary?
snapshot_def = _unwrap.snapshot_defs.find { |sd| sd.name == :last }
raise Nanoc::Core::Errors::NoSuchSnapshot.new(_unwrap, :last) if snapshot_def.nil?
snapshot_def.binary?
end
|
#eql?(other) ⇒ Boolean
28
29
30
31
32
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 28
def eql?(other)
other.is_a?(self.class) &&
item.eql?(other.item) &&
name.eql?(other.name)
end
|
#hash ⇒ Object
35
36
37
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 35
def hash
[self.class, item.identifier, name].hash
end
|
#inspect ⇒ Object
78
79
80
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 78
def inspect
"<#{self.class} item.identifier=#{item.identifier} name=#{name}>"
end
|
Returns the item that this item rep belongs to.
66
67
68
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 66
def item
item_view_class.new(@item_rep.item, @context)
end
|
#item_view_class ⇒ Object
13
14
15
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 13
def item_view_class
Nanoc::Core::BasicItemView
end
|
#name ⇒ Symbol
40
41
42
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 40
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.
58
59
60
61
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 58
def path(snapshot: :last)
@context.dependency_tracker.bounce(_unwrap.item, path: true)
@item_rep.path(snapshot:)
end
|
#snapshot?(name) ⇒ Boolean
44
45
46
47
|
# File 'lib/nanoc/core/basic_item_rep_view.rb', line 44
def snapshot?(name)
@context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
@item_rep.snapshot?(name)
end
|