class PutioFs::PutDir

Public Instance Methods

contents(path) click to toggle source
# File lib/putio_fs/put_dir.rb, line 93
def contents(path)
  puts "contents for #{path}"
  files = get_files(file_for_path(path).id)
  files.map { |x| x.name }
end
directory?(path) click to toggle source
# File lib/putio_fs/put_dir.rb, line 103
def directory?(path)
  puts "directory? for #{path}"
  file = hash_by_path[path]
  file.directory?
end
file?(path) click to toggle source
# File lib/putio_fs/put_dir.rb, line 98
def file?(path)
  puts "file? for #{path}"
  file = hash_by_path[path]
  file.file?
end
file_for_path(path) click to toggle source
# File lib/putio_fs/put_dir.rb, line 89
def file_for_path(path)
  hash_by_path["/"] ||= PutFile.new('id' => 0, 'put_dir' => self)
  hash_by_path[path]
end
get_files(root) click to toggle source
# File lib/putio_fs/put_dir.rb, line 73
def get_files(root)
  files = cached_responses[root]
  files.map do |raw|
    file = PutFile.new(raw.merge('put_dir' => self))

    hash_by_id[file.id] ||= file
    hash_by_name[file.name] ||= file
    hash_by_path[file.full_path] ||= file

    file
  end
end
read_file(path) click to toggle source
# File lib/putio_fs/put_dir.rb, line 108
def read_file(path)
  puts "read_file for #{path}"
  file = file_for_path(path)
  file.mp4_url
end
size(path) click to toggle source
# File lib/putio_fs/put_dir.rb, line 113
def size(path)
  puts "size for #{path}"
  read_file(path).size
end