Class: Cabriolet::Models::LITDirectoryEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/cabriolet/models/lit_header.rb

Overview

Represents a single directory entry

Entries use variable-length encoded integers to save space

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLITDirectoryEntry

Returns a new instance of LITDirectoryEntry.



125
126
127
128
129
130
# File 'lib/cabriolet/models/lit_header.rb', line 125

def initialize
  @name = ""
  @section = 0
  @offset = 0
  @size = 0
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



123
124
125
# File 'lib/cabriolet/models/lit_header.rb', line 123

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



123
124
125
# File 'lib/cabriolet/models/lit_header.rb', line 123

def offset
  @offset
end

#sectionObject

Returns the value of attribute section.



123
124
125
# File 'lib/cabriolet/models/lit_header.rb', line 123

def section
  @section
end

#sizeObject

Returns the value of attribute size.



123
124
125
# File 'lib/cabriolet/models/lit_header.rb', line 123

def size
  @size
end

Instance Method Details

#directoryString

Get the directory portion of the name

Returns:

  • Directory path



142
143
144
145
146
147
# File 'lib/cabriolet/models/lit_header.rb', line 142

def directory
  return "/" if root?

  parts = name.split("/")
  parts[0..-2].join("/")
end

#filenameString

Get the filename portion

Returns:

  • Filename



152
153
154
155
156
# File 'lib/cabriolet/models/lit_header.rb', line 152

def filename
  return "" if root?

  name.split("/").last
end

#root?Boolean

Check if this is a root entry

Returns:

  • true if root entry



135
136
137
# File 'lib/cabriolet/models/lit_header.rb', line 135

def root?
  ["/", ""].include?(name)
end