Class: Polygon::Content::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/polygon/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

The parent content



30
31
32
# File 'lib/polygon/content.rb', line 30

def content
  @content
end

#pathObject (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

Returns:

  • (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_sObject



53
54
55
# File 'lib/polygon/content.rb', line 53

def to_s
  path.to_s
end