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, #type

Instance Method Summary collapse

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ SayTimeAction

Returns a new instance of SayTimeAction.



2781
2782
2783
2784
2785
2786
2787
2788
2789
# File 'lib/ruby-macrodroid.rb', line 2781

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#invokeObject



2791
2792
2793
2794
2795
# File 'lib/ruby-macrodroid.rb', line 2791

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



2797
2798
2799
# File 'lib/ruby-macrodroid.rb', line 2797

def to_pc()
  'say current_time()'
end

#to_sObject



2801
2802
2803
# File 'lib/ruby-macrodroid.rb', line 2801

def to_s()
  'Say Current Time'
end