Class: NestedFile::PutDir

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
FromHash, Raw
Defined in:
lib/nested_file/put_dir.rb

Defined Under Namespace

Modules: Raw

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Raw

#raw_close, #raw_open, #raw_truncate, #raw_write

Instance Attribute Details

#mount_dirObject

Returns the value of attribute mount_dir.



23
24
25
# File 'lib/nested_file/put_dir.rb', line 23

def mount_dir
  @mount_dir
end

#parent_dirObject

Returns the value of attribute parent_dir.



23
24
25
# File 'lib/nested_file/put_dir.rb', line 23

def parent_dir
  @parent_dir
end

#relative_dirObject

Returns the value of attribute relative_dir.



23
24
25
# File 'lib/nested_file/put_dir.rb', line 23

def relative_dir
  @relative_dir
end

Instance Method Details

#can_write?(path) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/nested_file/put_dir.rb', line 83

def can_write?(path)
  true
end

#contents(path) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/nested_file/put_dir.rb', line 34

def contents(path)
  log "contents for #{path}" do
    parent_path = mount_to_parent(path)
    res = Dir.entries(parent_path)
    res.map { |x| File.basename(x) }
  end
end

#directory?(path) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/nested_file/put_dir.rb', line 44

def directory?(path)
  FileTest.directory? mount_to_parent(path)
end

#file?(path) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/nested_file/put_dir.rb', line 41

def file?(path)
  FileTest.file? mount_to_parent(path)
end

#read_file(path) ⇒ Object



51
52
53
54
55
# File 'lib/nested_file/put_dir.rb', line 51

def read_file(path)
  log "read file #{path}" do
    read_file_inner path
  end
end

#read_file_inner(path) ⇒ Object



47
48
49
50
# File 'lib/nested_file/put_dir.rb', line 47

def read_file_inner(path)
  body = File.read(mount_to_parent(path))
  PutFile.new(raw_body: body, filename: mount_to_parent(path), convert_path: relative_convert_path).parsed_body
end

#size(path) ⇒ Object



56
57
58
59
60
# File 'lib/nested_file/put_dir.rb', line 56

def size(path)
  log "size for #{path}" do
    read_file_inner(path).size
  end
end