Class: Eventkit::Timer

Inherits:
Struct
  • Object
show all
Defined in:
lib/eventkit/timer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seconds, handler) ⇒ Timer

Returns a new instance of Timer.



3
4
5
# File 'lib/eventkit/timer.rb', line 3

def initialize(seconds, handler)
  super(Time.now.to_f + seconds, handler)
end

Instance Attribute Details

#expires_inObject

Returns the value of attribute expires_in

Returns:

  • (Object)

    the current value of expires_in



2
3
4
# File 'lib/eventkit/timer.rb', line 2

def expires_in
  @expires_in
end

#handlerObject

Returns the value of attribute handler

Returns:

  • (Object)

    the current value of handler



2
3
4
# File 'lib/eventkit/timer.rb', line 2

def handler
  @handler
end

Instance Method Details

#<=>(other) ⇒ Object



7
8
9
# File 'lib/eventkit/timer.rb', line 7

def <=>(other)
  expires_in <=> other.expires_in
end

#expired?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/eventkit/timer.rb', line 11

def expired?
  expires_in <= Time.now.to_f
end