Class: SayTimeAction

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

Overview

Category: Date/Time

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #type

Instance Method Summary collapse

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ SayTimeAction

Returns a new instance of SayTimeAction.



2645
2646
2647
2648
2649
2650
2651
2652
2653
# File 'lib/ruby-macrodroid.rb', line 2645

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#invokeObject



2655
2656
2657
2658
2659
# File 'lib/ruby-macrodroid.rb', line 2655

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



2661
2662
2663
# File 'lib/ruby-macrodroid.rb', line 2661

def to_pc()
  'say current_time()'
end

#to_sObject



2665
2666
2667
# File 'lib/ruby-macrodroid.rb', line 2665

def to_s()
  'Say Current Time'
end