Class: SayTimeAction

Inherits:
DateTimeAction show all
Defined in:
lib/ruby-macrodroid/actions.rb

Overview

Category: Date/Time

Instance Attribute Summary

Attributes inherited from Action

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods included from ObjectX

#action_to_object, #object_create, #varify

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ SayTimeAction

Returns a new instance of SayTimeAction.



785
786
787
788
789
790
791
792
793
# File 'lib/ruby-macrodroid/actions.rb', line 785

def initialize(h={})

  options = {
    :'12_hour' => true
  }

  super(options.merge h)

end

Instance Method Details

#invokeObject



795
796
797
798
799
800
# File 'lib/ruby-macrodroid/actions.rb', line 795

def invoke()
  #time = ($env and $env[:time]) ? $env[:time] : Time.now
  time = Time.now
  tformat = @h['12_hour'] ? "%-I:%M%P" : "%H:%M"
  super(txt: time.strftime(tformat))
end

#to_pcObject



802
803
804
# File 'lib/ruby-macrodroid/actions.rb', line 802

def to_pc()
  'say current_time()'
end

#to_s(colour: false, indent: 0) ⇒ Object



806
807
808
# File 'lib/ruby-macrodroid/actions.rb', line 806

def to_s(colour: false, indent: 0)
  'Say Current Time'
end