Class: Hackmac::Graph

Inherits:
Object
  • Object
show all
Includes:
Term::ANSIColor
Defined in:
lib/hackmac/graph.rb,
lib/hackmac/graph/display.rb

Defined Under Namespace

Classes: Display

Instance Method Summary collapse

Constructor Details

#initialize(title:, value: -> i { 0 }, format_value: nil, sleep: nil, color: nil) ⇒ Graph

Returns a new instance of Graph.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/hackmac/graph.rb', line 42

def initialize(
  title:,
  value: -> i { 0 },
  format_value: nil,
  sleep: nil,
  color: nil
)
  sleep >= 0 or raise ArgumentError, 'sleep has to be >= 0'
  @title        = title
  @value        = value
  @format_value = format_value
  @sleep        = sleep
  @continue     = false
  @data         = []
  @color        = color
  @mutex        = Mutex.new
end

Instance Method Details

#startObject



60
61
62
63
64
# File 'lib/hackmac/graph.rb', line 60

def start
  install_handlers
  full_reset
  start_loop
end

#stopObject



66
67
68
69
# File 'lib/hackmac/graph.rb', line 66

def stop
  full_reset
  @continue = false
end