Class: SevenZipRuby::UpdateInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/seven_zip_ruby/update_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, param) ⇒ UpdateInfo

Returns a new instance of UpdateInfo.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/seven_zip_ruby/update_info.rb', line 17

def initialize(type, param)
  @type = type
  case(type)
  when :buffer
    name = param.delete(:name)
    data = param.delete(:data)
    initialize_buffer(name, data, param)
  when :dir
    name = param.delete(:name)
    initialize_dir(name, param)
  when :file
    initialize_file(param[:name], param[:filepath], param[:szw])
  end
end

Instance Attribute Details

#atimeObject (readonly)

Returns the value of attribute atime.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def atime
  @atime
end

#attribObject (readonly)

Returns the value of attribute attrib.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def attrib
  @attrib
end

#ctimeObject (readonly)

Returns the value of attribute ctime.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def ctime
  @ctime
end

#dataObject (readonly)

Returns the value of attribute data.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def data
  @data
end

#groupObject (readonly)

Returns the value of attribute group.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def group
  @group
end

#index_in_archiveObject (readonly)

Returns the value of attribute index_in_archive.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def index_in_archive
  @index_in_archive
end

#mtimeObject (readonly)

Returns the value of attribute mtime.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def mtime
  @mtime
end

#pathObject (readonly)

Returns the value of attribute path.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def path
  @path
end

#posix_attribObject (readonly)

Returns the value of attribute posix_attrib.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def posix_attrib
  @posix_attrib
end

#sizeObject (readonly)

Returns the value of attribute size.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def size
  @size
end

#userObject (readonly)

Returns the value of attribute user.



90
91
92
# File 'lib/seven_zip_ruby/update_info.rb', line 90

def user
  @user
end

Class Method Details

.buffer(name, data, opt = {}) ⇒ Object



4
5
6
# File 'lib/seven_zip_ruby/update_info.rb', line 4

def buffer(name, data, opt={})
  new(:buffer, opt.merge({ name: name, data: data }))
end

.dir(name, opt = {}) ⇒ Object



8
9
10
# File 'lib/seven_zip_ruby/update_info.rb', line 8

def dir(name, opt={})
  new(:dir, opt.merge({ name: name }))
end

.file(name, filepath, szw) ⇒ Object



12
13
14
# File 'lib/seven_zip_ruby/update_info.rb', line 12

def file(name, filepath, szw)
  new(:file, { name: name, filepath: filepath, szw: szw })
end

Instance Method Details

#anti?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/seven_zip_ruby/update_info.rb', line 112

def anti?
  return @anti
end

#buffer?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/seven_zip_ruby/update_info.rb', line 92

def buffer?
  return (@type == :buffer)
end

#directory?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/seven_zip_ruby/update_info.rb', line 96

def directory?
  return @dir
end

#file?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/seven_zip_ruby/update_info.rb', line 100

def file?
  return !(@dir)
end

#initialize_buffer(name, data, opt) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/seven_zip_ruby/update_info.rb', line 32

def initialize_buffer(name, data, opt)
  @index_in_archive = nil
  @new_data = true
  @new_properties = true
  @anti = false

  @path = name
  @dir = false
  @data = data
  @size = data.size
  @attrib = 0x20
  @posix_attrib = 0x00
  time = Time.now
  @ctime = (opt[:ctime] || time)
  @atime = (opt[:atime] || time)
  @mtime = (opt[:mtime] || time)
  @user = @group = nil
end

#initialize_dir(name, opt) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/seven_zip_ruby/update_info.rb', line 51

def initialize_dir(name, opt)
  @index_in_archive = nil
  @new_data = true
  @new_properties = true
  @anti = false

  @path = name
  @dir = true
  @data = nil
  @size = 0
  @attrib = 0x10
  @posix_attrib = 0x00
  time = Time.now
  @ctime = (opt[:ctime] || time)
  @atime = (opt[:atime] || time)
  @mtime = (opt[:mtime] || time)
  @user = @group = nil
end

#initialize_file(name, filepath, szw) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/seven_zip_ruby/update_info.rb', line 70

def initialize_file(name, filepath, szw)
  @index_in_archive = nil
  @new_data = true
  @new_properties = true
  @anti = false

  @path = name.to_s
  @dir = false
  filepath = Pathname(filepath).expand_path
  @data = filepath.to_s
  @size = filepath.size
  @attrib = (szw.get_file_attribute(filepath.to_s) || 0x20)
  @posix_attrib = 0x00
  @ctime = filepath.ctime
  @atime = filepath.atime
  @mtime = filepath.mtime
  @user = @group = nil
end

#new_data?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/seven_zip_ruby/update_info.rb', line 104

def new_data?
  return @new_data
end

#new_properties?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/seven_zip_ruby/update_info.rb', line 108

def new_properties?
  return @new_properties
end