Class: Taski::Progress::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/taski/progress/config.rb

Overview

Configuration for progress display. Holds class references for Layout and Theme, and builds display instances lazily.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&on_invalidate) ⇒ Config

Returns a new instance of Config.

Parameters:

  • on_invalidate (Proc, nil)

    Called when config changes (to clear external caches)



15
16
17
18
19
20
21
# File 'lib/taski/progress/config.rb', line 15

def initialize(&on_invalidate)
  @layout = nil
  @theme = nil
  @output = nil
  @cached_display = nil
  @on_invalidate = on_invalidate
end

Instance Attribute Details

#layoutObject

Returns the value of attribute layout.



12
13
14
# File 'lib/taski/progress/config.rb', line 12

def layout
  @layout
end

#outputObject

Returns the value of attribute output.



12
13
14
# File 'lib/taski/progress/config.rb', line 12

def output
  @output
end

#themeObject

Returns the value of attribute theme.



12
13
14
# File 'lib/taski/progress/config.rb', line 12

def theme
  @theme
end

Instance Method Details

#buildObject

Build a Layout instance from the current config. Returns a cached instance if config hasn't changed.



42
43
44
# File 'lib/taski/progress/config.rb', line 42

def build
  @cached_display ||= build_display
end

#resetObject

Reset all settings to defaults.



47
48
49
50
51
52
# File 'lib/taski/progress/config.rb', line 47

def reset
  @layout = nil
  @theme = nil
  @output = nil
  invalidate!
end