Class: E2B::Models::EntryInfo
- Inherits:
-
Object
- Object
- E2B::Models::EntryInfo
- Defined in:
- lib/e2b/models/entry_info.rb
Overview
Information about a filesystem entry (file or directory) in the sandbox
Represents the protobuf EntryInfo message returned by filesystem RPCs such as Stat, ListDir, and others. Contains metadata including name, type, path, size, permissions, ownership, and modification time.
Instance Attribute Summary collapse
-
#group ⇒ String
readonly
Group name.
-
#mode ⇒ Integer
readonly
Unix file mode (e.g., 0o644).
-
#modified_time ⇒ Time?
readonly
Last modification time.
-
#name ⇒ String
readonly
Name of the file or directory.
-
#owner ⇒ String
readonly
Owner username.
-
#path ⇒ String
readonly
Full path to the entry in the sandbox filesystem.
-
#permissions ⇒ String
readonly
Permissions string (e.g., “0644”).
-
#size ⇒ Integer
readonly
Size in bytes.
-
#symlink_target ⇒ String?
readonly
Symlink target path, if the entry is a symlink.
-
#type ⇒ String
readonly
Type of entry (one of FileType constants).
Class Method Summary collapse
-
.from_hash(data) ⇒ EntryInfo?
Create from RPC response hash.
Instance Method Summary collapse
-
#directory? ⇒ Boolean
Check if this entry is a directory.
-
#file? ⇒ Boolean
Check if this entry is a regular file.
-
#initialize(name:, type:, path:, size: 0, mode: 0, permissions: "", owner: "", group: "", modified_time: nil, symlink_target: nil) ⇒ EntryInfo
constructor
A new instance of EntryInfo.
Constructor Details
#initialize(name:, type:, path:, size: 0, mode: 0, permissions: "", owner: "", group: "", modified_time: nil, symlink_target: nil) ⇒ EntryInfo
Returns a new instance of EntryInfo.
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/e2b/models/entry_info.rb', line 143 def initialize(name:, type:, path:, size: 0, mode: 0, permissions: "", owner: "", group: "", modified_time: nil, symlink_target: nil) @name = name @type = type @path = path @size = size @mode = mode @permissions = @owner = owner @group = group @modified_time = modified_time @symlink_target = symlink_target end |
Instance Attribute Details
#group ⇒ String (readonly)
Returns Group name.
125 126 127 |
# File 'lib/e2b/models/entry_info.rb', line 125 def group @group end |
#mode ⇒ Integer (readonly)
Returns Unix file mode (e.g., 0o644).
116 117 118 |
# File 'lib/e2b/models/entry_info.rb', line 116 def mode @mode end |
#modified_time ⇒ Time? (readonly)
Returns Last modification time.
128 129 130 |
# File 'lib/e2b/models/entry_info.rb', line 128 def modified_time @modified_time end |
#name ⇒ String (readonly)
Returns Name of the file or directory.
104 105 106 |
# File 'lib/e2b/models/entry_info.rb', line 104 def name @name end |
#owner ⇒ String (readonly)
Returns Owner username.
122 123 124 |
# File 'lib/e2b/models/entry_info.rb', line 122 def owner @owner end |
#path ⇒ String (readonly)
Returns Full path to the entry in the sandbox filesystem.
110 111 112 |
# File 'lib/e2b/models/entry_info.rb', line 110 def path @path end |
#permissions ⇒ String (readonly)
Returns Permissions string (e.g., “0644”).
119 120 121 |
# File 'lib/e2b/models/entry_info.rb', line 119 def @permissions end |
#size ⇒ Integer (readonly)
Returns Size in bytes.
113 114 115 |
# File 'lib/e2b/models/entry_info.rb', line 113 def size @size end |
#symlink_target ⇒ String? (readonly)
Returns Symlink target path, if the entry is a symlink.
131 132 133 |
# File 'lib/e2b/models/entry_info.rb', line 131 def symlink_target @symlink_target end |
#type ⇒ String (readonly)
Returns Type of entry (one of FileType constants).
107 108 109 |
# File 'lib/e2b/models/entry_info.rb', line 107 def type @type end |
Class Method Details
.from_hash(data) ⇒ EntryInfo?
Create from RPC response hash
Handles both numeric protobuf enum values and string enum names, as well as camelCase and snake_case key formats.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/e2b/models/entry_info.rb', line 178 def self.from_hash(data) return nil unless data.is_a?(Hash) type_value = data["type"] || data[:type] type_name = case type_value when 1, "FILE_TYPE_FILE" then FileType::FILE when 2, "FILE_TYPE_DIRECTORY" then FileType::DIRECTORY else type_value.to_s end modified = data["modifiedTime"] || data["modified_time"] || data[:modifiedTime] || data[:modified_time] modified_time = parse_modified_time(modified) new( name: data["name"] || data[:name] || "", type: type_name, path: data["path"] || data[:path] || "", size: (data["size"] || data[:size] || 0).to_i, mode: (data["mode"] || data[:mode] || 0).to_i, permissions: data["permissions"] || data[:permissions] || "", owner: data["owner"] || data[:owner] || "", group: data["group"] || data[:group] || "", modified_time: modified_time, symlink_target: data["symlinkTarget"] || data["symlink_target"] || data[:symlinkTarget] || data[:symlink_target] ) end |