Class: E2B::Models::FilesystemEvent
- Inherits:
-
Object
- Object
- E2B::Models::FilesystemEvent
- Defined in:
- lib/e2b/models/entry_info.rb
Overview
Represents a filesystem event from directory watching
Filesystem events are emitted when files or directories change within a watched directory. Events are retrieved by polling via WatchHandle#get_new_events.
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Name of the file or directory that changed.
-
#type ⇒ String
readonly
Type of event (one of FilesystemEventType constants).
Class Method Summary collapse
-
.from_hash(data) ⇒ FilesystemEvent
Create from RPC response hash.
Instance Method Summary collapse
-
#initialize(name:, type:) ⇒ FilesystemEvent
constructor
A new instance of FilesystemEvent.
Constructor Details
#initialize(name:, type:) ⇒ FilesystemEvent
Returns a new instance of FilesystemEvent.
64 65 66 67 |
# File 'lib/e2b/models/entry_info.rb', line 64 def initialize(name:, type:) @name = name @type = type end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns Name of the file or directory that changed.
57 58 59 |
# File 'lib/e2b/models/entry_info.rb', line 57 def name @name end |
#type ⇒ String (readonly)
Returns Type of event (one of E2B::Models::FilesystemEventType constants).
60 61 62 |
# File 'lib/e2b/models/entry_info.rb', line 60 def type @type end |
Class Method Details
.from_hash(data) ⇒ FilesystemEvent
Create from RPC response hash
Handles both numeric protobuf enum values and string enum names.
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e2b/models/entry_info.rb', line 75 def self.from_hash(data) type_value = data["type"] || data[:type] type_name = case type_value when 1, "EVENT_TYPE_CREATE" then FilesystemEventType::CREATE when 2, "EVENT_TYPE_WRITE" then FilesystemEventType::WRITE when 3, "EVENT_TYPE_REMOVE" then FilesystemEventType::REMOVE when 4, "EVENT_TYPE_RENAME" then FilesystemEventType::RENAME when 5, "EVENT_TYPE_CHMOD" then FilesystemEventType::CHMOD else type_value.to_s end new(name: data["name"] || data[:name], type: type_name) end |