Class: RoadForest::Interface::Blob

Inherits:
Application
  • Object
show all
Defined in:
lib/roadforest/interface/blob.rb

Instance Attribute Summary

Attributes inherited from Application

#services

Instance Method Summary collapse

Methods inherited from Application

#canonical_host, #default_content_engine, #dispatcher, #initialize

Constructor Details

This class inherits a constructor from RoadForest::Application

Instance Method Details

#destination_dirObject



6
7
8
# File 'lib/roadforest/interface/blob.rb', line 6

def destination_dir
  Pathname.new(services.destination_dir)
end

#incomplete_pathObject



22
23
24
# File 'lib/roadforest/interface/blob.rb', line 22

def incomplete_path
  [path,"incomplete"].join(".")
end

#pathObject



14
15
16
# File 'lib/roadforest/interface/blob.rb', line 14

def path
  destination_dir.join(sub_path)
end

#retrieveObject



18
19
20
# File 'lib/roadforest/interface/blob.rb', line 18

def retrieve
  File::open(path)
end

#sub_pathObject



10
11
12
# File 'lib/roadforest/interface/blob.rb', line 10

def sub_path
  params.remainder
end

#update(incoming) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/roadforest/interface/blob.rb', line 26

def update(incoming)
  File::open(incomplete_path, "w") do |file|
    incoming.each do |chunk|
      file.write(chunk)
    end
  end
  Pathname.new(incomplete_path).rename(path)

  return nil
end