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.



2552
2553
2554
2555
2556
2557
2558
2559
2560
# File 'lib/ruby-macrodroid.rb', line 2552

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#invoke ⇒ Object



2562
2563
2564
2565
2566
# File 'lib/ruby-macrodroid.rb', line 2562

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_pc ⇒ Object



2568
2569
2570
# File 'lib/ruby-macrodroid.rb', line 2568

def to_pc()
  'say current_time()'
end

#to_s ⇒ Object



2572
2573
2574
# File 'lib/ruby-macrodroid.rb', line 2572

def to_s()
  'Say Current Time'
end