Class: Cabriolet::Models::LITDirectoryEntry
- Inherits:
-
Object
- Object
- Cabriolet::Models::LITDirectoryEntry
- 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
-
#name ⇒ Object
Returns the value of attribute name.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#section ⇒ Object
Returns the value of attribute section.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
-
#directory ⇒ String
Get the directory portion of the name.
-
#filename ⇒ String
Get the filename portion.
-
#initialize ⇒ LITDirectoryEntry
constructor
A new instance of LITDirectoryEntry.
-
#root? ⇒ Boolean
Check if this is a root entry.
Constructor Details
#initialize ⇒ LITDirectoryEntry
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
#name ⇒ Object
Returns the value of attribute name.
123 124 125 |
# File 'lib/cabriolet/models/lit_header.rb', line 123 def name @name end |
#offset ⇒ Object
Returns the value of attribute offset.
123 124 125 |
# File 'lib/cabriolet/models/lit_header.rb', line 123 def offset @offset end |
#section ⇒ Object
Returns the value of attribute section.
123 124 125 |
# File 'lib/cabriolet/models/lit_header.rb', line 123 def section @section end |
#size ⇒ Object
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
#directory ⇒ String
Get the directory portion of the name
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 |
#filename ⇒ String
Get the filename portion
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
135 136 137 |
# File 'lib/cabriolet/models/lit_header.rb', line 135 def root? ["/", ""].include?(name) end |