Class: PutioFs::PutDir

Inherits:
Object
  • Object
show all
Defined in:
lib/putio_fs/put_dir.rb

Instance Method Summary collapse

Instance Method Details

#contents(path) ⇒ Object



93
94
95
96
97
# 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) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
106
107
# 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) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
101
102
# 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) ⇒ Object



89
90
91
92
# 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) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# 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) ⇒ Object



108
109
110
111
112
# 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) ⇒ Object



113
114
115
116
# File 'lib/putio_fs/put_dir.rb', line 113

def size(path)
  puts "size for #{path}"
  read_file(path).size
end