Class: Omnizip::Formats::Iso::PathTable::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/formats/iso/path_table.rb

Overview

Path table entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, location, parent_directory_number) ⇒ Entry

Initialize entry

Parameters:

  • name (String)

    Directory name

  • location (Integer)

    LBA location

  • parent_directory_number (Integer)

    Parent directory index



20
21
22
23
24
# File 'lib/omnizip/formats/iso/path_table.rb', line 20

def initialize(name, location, parent_directory_number)
  @name = name
  @location = location
  @parent_directory_number = parent_directory_number
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



13
14
15
# File 'lib/omnizip/formats/iso/path_table.rb', line 13

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/omnizip/formats/iso/path_table.rb', line 13

def name
  @name
end

#parent_directory_numberObject (readonly)

Returns the value of attribute parent_directory_number.



13
14
15
# File 'lib/omnizip/formats/iso/path_table.rb', line 13

def parent_directory_number
  @parent_directory_number
end

Instance Method Details

#full_path(entries) ⇒ String

Get full path by traversing parent entries

Parameters:

  • entries (Array<Entry>)

    All path table entries

Returns:

  • (String)

    Full path



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/omnizip/formats/iso/path_table.rb', line 30

def full_path(entries)
  return "/" if @parent_directory_number == 1 # Root

  parts = [@name]
  current_parent = @parent_directory_number

  while current_parent > 1
    parent = entries[current_parent - 1]
    break unless parent

    parts.unshift(parent.name)
    current_parent = parent.parent_directory_number
  end

  "/#{parts.join('/')}"
end