Class: Downloads::Servers::Local

Inherits:
Base
  • Object
show all
Defined in:
lib/downloads/servers/local.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#exists?, #filenames

Constructor Details

#initialize(directory) ⇒ Local

Returns a new instance of Local.



6
7
8
# File 'lib/downloads/servers/local.rb', line 6

def initialize(directory)
  @directory = directory
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



4
5
6
# File 'lib/downloads/servers/local.rb', line 4

def directory
  @directory
end

Instance Method Details

#filesObject



10
11
12
13
14
# File 'lib/downloads/servers/local.rb', line 10

def files
  Dir.chdir(directory) do
    Dir.glob('*').sort.map { |name| { :name => name, :size => File.size(name) } }
  end
end

#rsync_pathObject



16
17
18
# File 'lib/downloads/servers/local.rb', line 16

def rsync_path
  "#{@directory}/"
end

#run(command) ⇒ Object



20
21
22
# File 'lib/downloads/servers/local.rb', line 20

def run(command)
  `sh -c "cd #{@directory}; #{command}"`
end