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 inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ SayTimeAction

Returns a new instance of SayTimeAction.



668
669
670
671
672
673
674
675
676
# File 'lib/ruby-macrodroid/actions.rb', line 668

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#invokeObject



678
679
680
681
682
# File 'lib/ruby-macrodroid/actions.rb', line 678

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

#to_pcObject



684
685
686
# File 'lib/ruby-macrodroid/actions.rb', line 684

def to_pc()
  'say current_time()'
end

#to_s(colour: false) ⇒ Object



688
689
690
# File 'lib/ruby-macrodroid/actions.rb', line 688

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