Class: Resilience::Image

Inherits:
Object
  • Object
show all
Includes:
Conf
Defined in:
lib/resilience/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Conf

conf, #conf, method_missing

Constructor Details

#initialize(args = {}) ⇒ Image

Returns a new instance of Image.



28
29
30
# File 'lib/resilience/image.rb', line 28

def initialize(args={})
  @file         = args[:file] || []
end

Instance Attribute Details

#bytes_per_sectorObject

Returns the value of attribute bytes_per_sector.



13
14
15
# File 'lib/resilience/image.rb', line 13

def bytes_per_sector
  @bytes_per_sector
end

#fileObject

Returns the value of attribute file.



9
10
11
# File 'lib/resilience/image.rb', line 9

def file
  @file
end

#object_tableObject

Returns the value of attribute object_table.



22
23
24
# File 'lib/resilience/image.rb', line 22

def object_table
  @object_table
end

#object_treeObject

Returns the value of attribute object_tree.



23
24
25
# File 'lib/resilience/image.rb', line 23

def object_tree
  @object_tree
end

#offsetObject

Returns the value of attribute offset.



10
11
12
# File 'lib/resilience/image.rb', line 10

def offset
  @offset
end

#optsObject

Returns the value of attribute opts.



11
12
13
# File 'lib/resilience/image.rb', line 11

def opts
  @opts
end

#pagesObject

all pages including shadow pages



26
27
28
# File 'lib/resilience/image.rb', line 26

def pages
  @pages
end

#root_dirObject

Returns the value of attribute root_dir.



20
21
22
# File 'lib/resilience/image.rb', line 20

def root_dir
  @root_dir
end

#sectors_per_clusterObject

Returns the value of attribute sectors_per_cluster.



14
15
16
# File 'lib/resilience/image.rb', line 14

def sectors_per_cluster
  @sectors_per_cluster
end

#system_tableObject

Returns the value of attribute system_table.



21
22
23
# File 'lib/resilience/image.rb', line 21

def system_table
  @system_table
end

Instance Method Details

#cluster_sizeObject



16
17
18
# File 'lib/resilience/image.rb', line 16

def cluster_size
  @cluster_size ||= bytes_per_sector * sectors_per_cluster
end

#parseObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/resilience/image.rb', line 32

def parse
  parse_bounds

  # each of these is a seperate parsing process,
  # though later ones may depend on former
  @pages        = Resilience::Page.extract_all  if conf.pages?
  @system_table = Resilience::SystemTable.parse
  @object_table = Resilience::ObjectTable.parse
  @root_dir     = Resilience::RootDir.parse
  @object_tree  = Resilience::ObjectTree.parse  if conf.object_tree?
end

#posObject



48
49
50
# File 'lib/resilience/image.rb', line 48

def pos
  @file.pos - offset
end

#read(len) ⇒ Object



56
57
58
# File 'lib/resilience/image.rb', line 56

def read(len)
  @file.read(len)
end

#seek(position) ⇒ Object



44
45
46
# File 'lib/resilience/image.rb', line 44

def seek(position)
  @file.seek offset + position
end

#total_posObject



52
53
54
# File 'lib/resilience/image.rb', line 52

def total_pos
  @file.pos
end