Class: Ticker

Inherits:
Object
  • Object
show all
Defined in:
lib/sqs_cli/ticker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count = 0, opts = {}) ⇒ Ticker

Returns a new instance of Ticker.



4
5
6
7
8
# File 'lib/sqs_cli/ticker.rb', line 4

def initialize(count=0, opts={})
  @count = count
  @silent = opts.fetch(:silent, false)
  @start_time = Time.now
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



2
3
4
# File 'lib/sqs_cli/ticker.rb', line 2

def count
  @count
end

Instance Method Details

#incrementObject



10
11
12
13
# File 'lib/sqs_cli/ticker.rb', line 10

def increment
  print "." unless @silent
  @count += 1
end

#uptimeObject



15
16
17
18
# File 'lib/sqs_cli/ticker.rb', line 15

def uptime
  @end_time = Time.now
  (@end_time - @start_time).round(2)
end