Class: Distillery::ROM::Path::Archive
- Inherits:
-
Distillery::ROM::Path
- Object
- Distillery::ROM::Path
- Distillery::ROM::Path::Archive
- Defined in:
- lib/distillery/rom/path/archive.rb
Overview
Path from archive, binding archive and entry together.
Instance Attribute Summary collapse
-
#archive ⇒ ROMArchive
readonly
Returns the value of attribute archive.
Class Method Summary collapse
-
.separator ⇒ String, Array
Get the separator used to distinguish archive file from entry.
-
.separator=(sep) ⇒ Object
Set the separator used to distinguish archive file from entry.
Instance Method Summary collapse
-
#basename ⇒ String
Get path basename.
-
#copy(to, length = nil, offset = 0, force: false, link: :hard) ⇒ Boolean
Copy ROM content to the filesystem, possibly using link if requested.
-
#delete! ⇒ Boolean
Delete physical content.
-
#entry ⇒ String
Entry.
-
#file ⇒ String
File directly accessible on the file system.
- #grouping ⇒ Object
-
#initialize(archive, entry) ⇒ Archive
constructor
Create a an Archive Path instance.
-
#reader {|io| ... } ⇒ Object
ROM reader.
-
#rename(path, force: false) ⇒ Boolean
Rename ROM and physical content.
-
#storage ⇒ String
File or directory that is considered the storage space for entries.
-
#to_s(separator = nil) ⇒ String
Path value as string.
Constructor Details
#initialize(archive, entry) ⇒ Archive
Create a an Archive Path instance
37 38 39 40 |
# File 'lib/distillery/rom/path/archive.rb', line 37 def initialize(archive, entry) @archive = archive @entry = entry end |
Instance Attribute Details
#archive ⇒ ROMArchive (readonly)
Returns the value of attribute archive
97 98 99 |
# File 'lib/distillery/rom/path/archive.rb', line 97 def archive @archive end |
Class Method Details
.separator ⇒ String, Array
Get the separator used to distinguish archive file from entry
27 28 29 |
# File 'lib/distillery/rom/path/archive.rb', line 27 def self.separator @@separator end |
.separator=(sep) ⇒ Object
Set the separator used to distinguish archive file from entry
18 19 20 |
# File 'lib/distillery/rom/path/archive.rb', line 18 def self.separator=(sep) @@separator = sep.dup.freeze end |
Instance Method Details
#basename ⇒ String
Get path basename
64 65 66 |
# File 'lib/distillery/rom/path/archive.rb', line 64 def basename ::File.basename(self.entry) end |
#copy(to, length = nil, offset = 0, force: false, link: :hard) ⇒ Boolean
Copy ROM content to the filesystem, possibly using link if requested.
79 80 81 82 |
# File 'lib/distillery/rom/path/archive.rb', line 79 def copy(to, length = nil, offset = 0, force: false, link: :hard) # XXX: improve like String @archive.extract(@entry, to, length, offset, force: force) end |
#delete! ⇒ Boolean
Delete physical content.
91 92 93 |
# File 'lib/distillery/rom/path/archive.rb', line 91 def delete! @archive.delete!(@entry) end |
#entry ⇒ String
Entry
59 60 61 |
# File 'lib/distillery/rom/path/archive.rb', line 59 def entry @entry end |
#file ⇒ String
File directly accessible on the file system
49 50 51 |
# File 'lib/distillery/rom/path/archive.rb', line 49 def file @archive.file end |
#grouping ⇒ Object
69 70 71 |
# File 'lib/distillery/rom/path/archive.rb', line 69 def grouping [ self.storage, self.entry, @archive.size ] end |
#reader {|io| ... } ⇒ Object
Can be costly, prefer existing #copy if possible
ROM reader
74 75 76 |
# File 'lib/distillery/rom/path/archive.rb', line 74 def reader(&block) @archive.reader(@entry, &block) end |
#rename(path, force: false) ⇒ Boolean
Renaming could lead to silent removing if same ROM is on its way
Rename ROM and physical content.
85 86 87 88 |
# File 'lib/distillery/rom/path/archive.rb', line 85 def rename(path, force: false) # XXX: improve like String @archive.rename(@entry, path, force: force) end |
#storage ⇒ String
File or directory that is considered the storage space for entries
54 55 56 |
# File 'lib/distillery/rom/path/archive.rb', line 54 def storage self.file end |
#to_s(separator = nil) ⇒ String
Path value as string.
43 44 45 46 |
# File 'lib/distillery/rom/path/archive.rb', line 43 def to_s(separator = nil) separator ||= @@separator "#{self.file}#{separator[0]}#{self.entry}#{separator[1]}" end |