Class: Quiver::Adapter::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/quiver/adapter/local.rb

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Local

Returns a new instance of Local.



4
5
6
# File 'lib/quiver/adapter/local.rb', line 4

def initialize(root)
  @root = Pathname.new(root)
end

Instance Method Details

#each(path, ext) ⇒ Object



10
11
12
13
14
15
# File 'lib/quiver/adapter/local.rb', line 10

def each(path, ext)
  @root.join(path).each_child(false) do |entry|
    next unless entry.to_s.end_with?(".#{ext}")
    yield entry
  end
end

#image_url(path) ⇒ Object



7
8
9
# File 'lib/quiver/adapter/local.rb', line 7

def image_url(path)
  "file://" + path.to_s
end

#load(path) ⇒ Object



16
17
18
# File 'lib/quiver/adapter/local.rb', line 16

def load(path)
  File.read @root.join(path)
end

#mkpath(path) ⇒ Object



19
20
21
# File 'lib/quiver/adapter/local.rb', line 19

def mkpath(path)
  @root.join(path).mkpath
end

#save(path, content) ⇒ Object



22
23
24
# File 'lib/quiver/adapter/local.rb', line 22

def save(path, content)
  @root.join(path).write(content)
end