Class: InVFS::Zip

Inherits:
Object show all
Defined in:
lib/invfs/zip.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Zip

Returns a new instance of Zip.



13
14
15
16
17
# File 'lib/invfs/zip.rb', line 13

def initialize(path)
  @path = String(path)
  @zip = Zip::File.open(@path)
  @zipfile = @zip.file
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/invfs/zip.rb', line 11

def path
  @path
end

#zipObject (readonly)

Returns the value of attribute zip.



11
12
13
# File 'lib/invfs/zip.rb', line 11

def zip
  @zip
end

#zipfileObject (readonly)

Returns the value of attribute zipfile.



11
12
13
# File 'lib/invfs/zip.rb', line 11

def zipfile
  @zipfile
end

Instance Method Details

#file?(path) ⇒ Boolean

call-seq:

file?(path) -> true OR false (OR nil)

REQUIRED method for VFS.

Returns:

  • (Boolean)


37
38
39
# File 'lib/invfs/zip.rb', line 37

def file?(path)
  zipfile.file?(path)
end

#inspectObject



68
69
70
# File 'lib/invfs/zip.rb', line 68

def inspect
  %(#<#{self.class}:#{path}>)
end

#pretty_print(q) ⇒ Object



72
73
74
# File 'lib/invfs/zip.rb', line 72

def pretty_print(q)
  q.text inspect
end

#read(path) ⇒ Object

call-seq:

read(path) -> string

REQUIRED method for VFS.



57
58
59
# File 'lib/invfs/zip.rb', line 57

def read(path)
  zipfile.read(path)
end

#size(path) ⇒ Object

call-seq:

size(path) -> integer for file size

REQUIRED method for VFS.



47
48
49
# File 'lib/invfs/zip.rb', line 47

def size(path)
  zipfile.size(path)
end

#to_pathObject

call-seq:

to_path -> string

REQUIRED method for VFS.

This value MUST be not modifying in each objects.



27
28
29
# File 'lib/invfs/zip.rb', line 27

def to_path
  path
end

#to_sObject

optional method for VFS.



64
65
66
# File 'lib/invfs/zip.rb', line 64

def to_s
  %(#{path} (#{self.class}))
end