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.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 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 |
# File 'lib/ruby-macrodroid/actions.rb', line 313 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
380 381 382 383 |
# File 'lib/ruby-macrodroid/actions.rb', line 380 def to_pc() camera = @h[:use_front_camera] ? :front : :back 'take_photo :' + camera.to_s end |
#to_s(colour: false, indent: 0) ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/ruby-macrodroid/actions.rb', line 385 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 |