Class: SayTimeAction

Inherits:
DateTimeAction show all
Defined in:
lib/ruby-macrodroid.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.



2888
2889
2890
2891
2892
2893
2894
2895
2896
# File 'lib/ruby-macrodroid.rb', line 2888

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#invokeObject



2898
2899
2900
2901
2902
# File 'lib/ruby-macrodroid.rb', line 2898

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



2904
2905
2906
# File 'lib/ruby-macrodroid.rb', line 2904

def to_pc()
  'say current_time()'
end

#to_sObject



2908
2909
2910
# File 'lib/ruby-macrodroid.rb', line 2908

def to_s()
  'Say Current Time'
end