Class: Polygon::Content::Entry
- Inherits:
-
Object
- Object
- Polygon::Content::Entry
- Defined in:
- lib/polygon/content.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
The parent content.
-
#path ⇒ Object
readonly
Path to the file containing this content.
Instance Method Summary collapse
- #/(arg) ⇒ Object
- #==(other) ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(content, path) ⇒ Entry
constructor
A new instance of Entry.
- #to_hash(with_ancestors = true) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(content, path) ⇒ Entry
Returns a new instance of Entry.
35 36 37 |
# File 'lib/polygon/content.rb', line 35 def initialize(content, path) @content, @path = content, path end |
Instance Attribute Details
#content ⇒ Object (readonly)
The parent content
30 31 32 |
# File 'lib/polygon/content.rb', line 30 def content @content end |
#path ⇒ Object (readonly)
Path to the file containing this content
33 34 35 |
# File 'lib/polygon/content.rb', line 33 def path @path end |
Instance Method Details
#/(arg) ⇒ Object
43 44 45 |
# File 'lib/polygon/content.rb', line 43 def /(arg) content.entry(path/arg) end |
#==(other) ⇒ Object
47 48 49 50 51 |
# File 'lib/polygon/content.rb', line 47 def ==(other) other.is_a?(Entry) and other.content == content and other.path == path end |
#exist? ⇒ Boolean
39 40 41 |
# File 'lib/polygon/content.rb', line 39 def exist? path.exist? end |
#to_hash(with_ancestors = true) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/polygon/content.rb', line 57 def to_hash(with_ancestors = true) if with_ancestors ancestors_or_self(true).inject({}) do |h,content| merge(h, content.data) end else data end end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/polygon/content.rb', line 53 def to_s path.to_s end |