Class: GoodLuckCharm
- Inherits:
-
Object
- Object
- GoodLuckCharm
- Defined in:
- lib/good_luck_charm/good_luck_charm.rb,
lib/good_luck_charm/version.rb
Overview
This utility can be used by writing a good luck charm. “‘rb
loop do
(@charm ||= GoodLuckCharm.new).tondeke!
if @charm.changed_per?(60)
puts 'kana' # this statement is called only once in a minute)
end
sleep 1
end
““
Constant Summary collapse
- VERSION =
'0.1.1'
Instance Method Summary collapse
-
#changed_per?(seconds, init: false) ⇒ Boolean
returns true once a specified period.
-
#tondeke! ⇒ Object
飛んでけ!.
Instance Method Details
#changed_per?(seconds, init: false) ⇒ Boolean
returns true once a specified period
26 27 28 29 30 |
# File 'lib/good_luck_charm/good_luck_charm.rb', line 26 def changed_per?(seconds, init: false) return init unless @last_time && Time.now @last_time.ceil_to(seconds) <= Time.now end |
#tondeke! ⇒ Object
飛んでけ!
17 18 19 20 21 |
# File 'lib/good_luck_charm/good_luck_charm.rb', line 17 def tondeke! @last_time = @current_time @current_time = Time.now self end |