Class: SayTimeAction
- Inherits:
-
DateTimeAction
- Object
- MacroObject
- Action
- DateTimeAction
- SayTimeAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Overview
Category: Date/Time
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ SayTimeAction
constructor
A new instance of SayTimeAction.
- #invoke ⇒ Object
- #to_pc ⇒ Object
- #to_s(colour: false, indent: 0) ⇒ Object
Methods included from ObjectX
#action_to_object, #object_create, #varify
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ SayTimeAction
Returns a new instance of SayTimeAction.
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 |
# File 'lib/ruby-macrodroid/actions.rb', line 917 def initialize(obj=nil) h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro = obj {:'12_hour' => e.text('item/description').to_s[/^\d+/] == '12'} end = { :'12_hour' => true } super(.merge h) end |
Instance Method Details
#invoke ⇒ Object
936 937 938 939 940 941 |
# File 'lib/ruby-macrodroid/actions.rb', line 936 def invoke() #time = ($env and $env[:time]) ? $env[:time] : Time.now time = Time.now tformat = @h['12_hour'] ? "%-I:%M%P" : "%H:%M" super(txt: time.strftime(tformat)) end |
#to_pc ⇒ Object
943 944 945 |
# File 'lib/ruby-macrodroid/actions.rb', line 943 def to_pc() 'say current_time()' end |
#to_s(colour: false, indent: 0) ⇒ Object
947 948 949 950 951 |
# File 'lib/ruby-macrodroid/actions.rb', line 947 def to_s(colour: false, indent: 0) @s = 'Say Current Time' @s += "\n%s hour clock" % (@h[:'12_hour'] ? '12' : '24') super() end |