Class: Nanoc::Core::ItemRep
- Inherits:
-
Object
- Object
- Nanoc::Core::ItemRep
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/item_rep.rb
Instance Attribute Summary collapse
-
#compiled ⇒ Object
(also: #compiled?)
Returns the value of attribute compiled.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#modified ⇒ Object
(also: #modified?)
Returns the value of attribute modified.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#raw_paths ⇒ Object
Returns the value of attribute raw_paths.
-
#snapshot_defs ⇒ Object
Returns the value of attribute snapshot_defs.
Instance Method Summary collapse
-
#initialize(item, name) ⇒ ItemRep
constructor
A new instance of ItemRep.
- #inspect ⇒ Object
-
#path(snapshot: :last) ⇒ Object
Returns the item rep’s path, as used when being linked to.
-
#raw_path(snapshot: :last) ⇒ Object
Returns the item rep’s raw path.
-
#reference ⇒ Object
Returns an object that can be used for uniquely identifying objects.
- #snapshot?(name) ⇒ Boolean
- #to_s ⇒ Object
Methods included from ContractsSupport
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(item, name) ⇒ ItemRep
Returns a new instance of ItemRep.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nanoc/core/item_rep.rb', line 32 def initialize(item, name) # Set primary attributes @item = item @name = name # Set default attributes @raw_paths = {} @paths = {} @snapshot_defs = [] # Reset flags @compiled = false @modified = false end |
Instance Attribute Details
#compiled ⇒ Object Also known as: compiled?
Returns the value of attribute compiled.
9 10 11 |
# File 'lib/nanoc/core/item_rep.rb', line 9 def compiled @compiled end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
19 20 21 |
# File 'lib/nanoc/core/item_rep.rb', line 19 def item @item end |
#modified ⇒ Object Also known as: modified?
Returns the value of attribute modified.
28 29 30 |
# File 'lib/nanoc/core/item_rep.rb', line 28 def modified @modified end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/nanoc/core/item_rep.rb', line 22 def name @name end |
#paths ⇒ Object
Returns the value of attribute paths.
16 17 18 |
# File 'lib/nanoc/core/item_rep.rb', line 16 def paths @paths end |
#raw_paths ⇒ Object
Returns the value of attribute raw_paths.
13 14 15 |
# File 'lib/nanoc/core/item_rep.rb', line 13 def raw_paths @raw_paths end |
#snapshot_defs ⇒ Object
Returns the value of attribute snapshot_defs.
25 26 27 |
# File 'lib/nanoc/core/item_rep.rb', line 25 def snapshot_defs @snapshot_defs end |
Instance Method Details
#inspect ⇒ Object
87 88 89 |
# File 'lib/nanoc/core/item_rep.rb', line 87 def inspect "<#{self.class} name=\"#{name}\" raw_path=\"#{raw_path}\" item.identifier=\"#{item.identifier}\">" end |
#path(snapshot: :last) ⇒ Object
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.
74 75 76 |
# File 'lib/nanoc/core/item_rep.rb', line 74 def path(snapshot: :last) @paths.fetch(snapshot, []).first end |
#raw_path(snapshot: :last) ⇒ Object
Returns the item rep’s raw path. It includes the path to the output directory and the full filename.
65 66 67 |
# File 'lib/nanoc/core/item_rep.rb', line 65 def raw_path(snapshot: :last) @raw_paths.fetch(snapshot, []).first end |
#reference ⇒ Object
Returns an object that can be used for uniquely identifying objects.
79 80 81 |
# File 'lib/nanoc/core/item_rep.rb', line 79 def reference "item_rep:#{item.identifier}:#{name}" end |
#snapshot?(name) ⇒ Boolean
58 59 60 |
# File 'lib/nanoc/core/item_rep.rb', line 58 def snapshot?(name) snapshot_defs.any? { |sd| sd.name == name } end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/nanoc/core/item_rep.rb', line 83 def to_s "#{item.identifier} (rep name #{name.inspect})" end |