Class: Ruflet::UI::Controls::RufletComponents::ScreenshotControl

Inherits:
Control
  • Object
show all
Defined in:
lib/ruflet_ui/ruflet/ui/controls/shared/screenshot_control.rb

Constant Summary collapse

TYPE =
"screenshot".freeze
WIRE =
"Screenshot".freeze
KEYWORDS =
[:badge, :col, :content, :data, :disabled, :expand, :expand_loose, :key, :opacity, :rtl, :tooltip, :visible].freeze

Constants inherited from Control

Control::HOST_EXPANDED_TYPES, Control::SCHEMA_METADATA_CACHE

Instance Attribute Summary

Attributes inherited from Control

#children, #id, #props, #runtime_page, #type, #wire_id

Instance Method Summary collapse

Methods inherited from Control

#attach_handler, #emit, generate_id, #has_handler?, #merge_props, #on, #to_patch

Constructor Details

#initialize(id: nil, badge: nil, col: nil, content: nil, data: nil, disabled: nil, expand: nil, expand_loose: nil, key: nil, opacity: nil, rtl: nil, tooltip: nil, visible: nil) ⇒ ScreenshotControl

Returns a new instance of ScreenshotControl.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/screenshot_control.rb', line 12

def initialize(id: nil, badge: nil, col: nil, content: nil, data: nil, disabled: nil, expand: nil, expand_loose: nil, key: nil, opacity: nil, rtl: nil, tooltip: nil, visible: nil)
  raise ArgumentError, "missing keyword: :content" if content.nil?

  props = {}
  props[:badge] = badge unless badge.nil?
  props[:col] = col unless col.nil?
  props[:content] = content unless content.nil?
  props[:data] = data unless data.nil?
  props[:disabled] = disabled unless disabled.nil?
  props[:expand] = expand unless expand.nil?
  props[:expand_loose] = expand_loose unless expand_loose.nil?
  props[:key] = key unless key.nil?
  props[:opacity] = opacity unless opacity.nil?
  props[:rtl] = rtl unless rtl.nil?
  props[:tooltip] = tooltip unless tooltip.nil?
  props[:visible] = visible unless visible.nil?
  super(type: TYPE, id: id, **props)
end

Instance Method Details

#capture(pixel_ratio: nil, delay: nil, timeout: 10, on_result: nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/screenshot_control.rb', line 31

def capture(pixel_ratio: nil, delay: nil, timeout: 10, on_result: nil)
  args = {}
  args["pixel_ratio"] = pixel_ratio unless pixel_ratio.nil?
  args["delay"] = delay unless delay.nil?
  runtime_page&.invoke(
    self,
    "capture",
    args: args.empty? ? nil : args,
    timeout: timeout,
    on_result: on_result
  )
end