Class: Ruflet::UI::Services::RufletServicesComponents::CameraControl

Inherits:
Control
  • Object
show all
Defined in:
lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb

Constant Summary collapse

TYPE =
"camera".freeze
WIRE =
"Camera".freeze
KEYWORDS =
[:align, :animate_align, :animate_margin, :animate_offset, :animate_opacity, :animate_position, :animate_rotation, :animate_scale, :animate_size, :aspect_ratio, :badge, :bottom, :col, :content, :data, :disabled, :expand, :expand_loose, :height, :key, :left, :margin, :offset, :opacity, :preview_enabled, :right, :rotate, :rtl, :scale, :size_change_interval, :tooltip, :top, :visible, :width, :on_animation_end, :on_error, :on_size_change, :on_state_change, :on_stream_image].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, **props) ⇒ CameraControl

Returns a new instance of CameraControl.



13
14
15
16
17
18
19
20
# File 'lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb', line 13

def initialize(id: nil, **props)
  compact = {}
  props.each do |key, value|
    raise ArgumentError, "unknown keyword: :#{key}" unless KEYWORDS.include?(key)
    compact[key] = value unless value.nil?
  end
  super(type: TYPE, id: id, **compact)
end

Instance Method Details

#initialize_camera(description, resolution_preset, enable_audio: true, fps: nil, video_bitrate: nil, audio_bitrate: nil, image_format_group: nil, timeout: 10, on_result: nil) ⇒ Object

Ruby reserves #initialize for object construction, so the Flet Camera.initialize() operation is exposed as #initialize_camera.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb', line 37

def initialize_camera(description, resolution_preset, enable_audio: true, fps: nil,
                      video_bitrate: nil, audio_bitrate: nil,
                      image_format_group: nil, timeout: 10, on_result: nil)
  invoke_camera(
    "initialize",
    args: compact_args(
      description: description,
      resolution_preset: resolution_preset,
      enable_audio: enable_audio,
      fps: fps,
      video_bitrate: video_bitrate,
      audio_bitrate: audio_bitrate,
      image_format_group: image_format_group
    ),
    timeout: timeout,
    on_result: on_result
  )
end

#lock_capture_orientation(orientation = nil, timeout: 10, on_result: nil) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb', line 56

def lock_capture_orientation(orientation = nil, timeout: 10, on_result: nil)
  invoke_camera(
    "lock_capture_orientation",
    args: { "orientation" => normalize_value(orientation) },
    timeout: timeout,
    on_result: on_result
  )
end