Class: TakePictureAction
- Inherits:
-
CameraAction
- Object
- MacroObject
- Action
- CameraAction
- TakePictureAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Overview
Category: Camera/Photo
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ TakePictureAction
constructor
A new instance of TakePictureAction.
- #to_pc ⇒ Object
- #to_s(colour: false, indent: 0) ⇒ Object
Methods inherited from Action
Methods included from ObjectX
#action_to_object, #object_create, #varify
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ TakePictureAction
Returns a new instance of TakePictureAction.
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/ruby-macrodroid/actions.rb', line 345 def initialize(obj=nil) h = if obj.is_a? Hash then macro = obj[:macro] obj.delete :macro obj elsif obj.is_a? Array e, macro = obj #puts 'e: ' + e.xml.inspect a = e.xpath('item/*') if a.any? then h2 = a.map {|node| [node.name.to_sym, node.text.to_s.strip]}.to_h desc = '' if h2[:description] then desc = h2[:description] h2.delete :description #puts 'desc: ' + desc.inspect if desc.length > 1 then flash = case desc when /Flash On/i 1 when /Flash Auto/i 2 else 0 end end end { use_front_camera: (desc =~ /Front Facing/ ? true : false), flash_option: flash }.merge(h2) end end = { new_path: macro.picture_path, path: macro.picture_path, show_icon: true, use_front_camera: true, flash_option: 0 } super(.merge h) end |
Instance Method Details
#to_pc ⇒ Object
412 413 414 415 |
# File 'lib/ruby-macrodroid/actions.rb', line 412 def to_pc() camera = @h[:use_front_camera] ? :front : :back 'take_photo :' + camera.to_s end |
#to_s(colour: false, indent: 0) ⇒ Object
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/ruby-macrodroid/actions.rb', line 417 def to_s(colour: false, indent: 0) flash = case @h[:flash_option] when 0 '' when 1 'Flash On' when 2 'Flash Auto' end @s = 'Take Picture'# + @h.inspect a = [@h[:use_front_camera] ? 'Front Facing' : 'Rear Facing'] a << flash if flash.length > 0 @s += "\n" + a.join(', ') super() end |