Class: Polygon::Content

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

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, loader = Polygon.default_loader) ⇒ Content

Creates a Content instance



13
14
15
16
# File 'lib/polygon/content.rb', line 13

def initialize(path, loader = Polygon.default_loader)
  @path = path
  @loader = loader
end

Instance Attribute Details

#loaderObject (readonly)

Underlying content loader



10
11
12
# File 'lib/polygon/content.rb', line 10

def loader
  @loader
end

#pathObject (readonly)

Root of the content folders



7
8
9
# File 'lib/polygon/content.rb', line 7

def path
  @path
end

Instance Method Details

#entry(path) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/polygon/content.rb', line 18

def entry(path)
  if path.relative?
    path = @path/path
  elsif path.outside?(@path)
    return nil
  end
  Entry.new(self, path)
end