Class: Daytona::ComputerUse::Screenshot
- Inherits:
-
Object
- Object
- Daytona::ComputerUse::Screenshot
- Defined in:
- lib/daytona/computer_use.rb
Overview
Screenshot operations for computer use functionality.
Instance Attribute Summary collapse
-
#sandbox_id ⇒ String
readonly
The ID of the sandbox.
-
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi
readonly
API client for sandbox operations.
Instance Method Summary collapse
-
#initialize(sandbox_id:, toolbox_api:) ⇒ Screenshot
constructor
A new instance of Screenshot.
-
#take_compressed(options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of the entire screen.
-
#take_compressed_region(region:, options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of a specific region.
-
#take_full_screen(show_cursor: false) ⇒ DaytonaApiClient::ScreenshotResponse
Takes a screenshot of the entire screen.
-
#take_region(region:, show_cursor: false) ⇒ DaytonaApiClient::RegionScreenshotResponse
Takes a screenshot of a specific region.
Constructor Details
#initialize(sandbox_id:, toolbox_api:) ⇒ Screenshot
Returns a new instance of Screenshot.
209 210 211 212 |
# File 'lib/daytona/computer_use.rb', line 209 def initialize(sandbox_id:, toolbox_api:) @sandbox_id = sandbox_id @toolbox_api = toolbox_api end |
Instance Attribute Details
#sandbox_id ⇒ String (readonly)
Returns The ID of the sandbox.
202 203 204 |
# File 'lib/daytona/computer_use.rb', line 202 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
205 206 207 |
# File 'lib/daytona/computer_use.rb', line 205 def toolbox_api @toolbox_api end |
Instance Method Details
#take_compressed(options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of the entire screen.
268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/daytona/computer_use.rb', line 268 def take_compressed(options: nil) ||= ScreenshotOptions.new toolbox_api.take_compressed_screenshot( sandbox_id, scale: .scale, quality: .quality, format: .fmt, show_cursor: .show_cursor ) rescue StandardError => e raise Sdk::Error, "Failed to take compressed screenshot: #{e.}" end |
#take_compressed_region(region:, options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of a specific region.
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/daytona/computer_use.rb', line 295 def take_compressed_region(region:, options: nil) # rubocop:disable Metrics/MethodLength ||= ScreenshotOptions.new toolbox_api.take_compressed_region_screenshot( sandbox_id, region.height, region.width, region.y, region.x, scale: .scale, quality: .quality, format: .fmt, show_cursor: .show_cursor ) rescue StandardError => e raise Sdk::Error, "Failed to take compressed region screenshot: #{e.}" end |
#take_full_screen(show_cursor: false) ⇒ DaytonaApiClient::ScreenshotResponse
Takes a screenshot of the entire screen.
226 227 228 229 230 |
# File 'lib/daytona/computer_use.rb', line 226 def take_full_screen(show_cursor: false) toolbox_api.take_screenshot(show_cursor:) rescue StandardError => e raise Sdk::Error, "Failed to take screenshot: #{e.}" end |
#take_region(region:, show_cursor: false) ⇒ DaytonaApiClient::RegionScreenshotResponse
Takes a screenshot of a specific region.
243 244 245 246 247 |
# File 'lib/daytona/computer_use.rb', line 243 def take_region(region:, show_cursor: false) toolbox_api.take_region_screenshot(region.height, region.width, region.y, region.x, show_cursor:) rescue StandardError => e raise Sdk::Error, "Failed to take region screenshot: #{e.}" end |