Class: CommandLineReporter::ProgressFormatter

Inherits:
Object
  • Object
show all
Includes:
OptionsValidator, Singleton
Defined in:
lib/command_line_reporter/formatter/progress.rb

Constant Summary collapse

VALID_OPTIONS =
[:indicator, :color, :bold]

Instance Method Summary collapse

Methods included from OptionsValidator

#validate_options

Instance Method Details

#format(options, block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/command_line_reporter/formatter/progress.rb', line 12

def format(options, block)
  self.validate_options(options, *VALID_OPTIONS)

  self.indicator = options[:indicator] if options[:indicator]
  self.color = options[:color]
  self.bold = options[:bold] || false

  block.call

  puts
end

#indicatorObject



33
34
35
# File 'lib/command_line_reporter/formatter/progress.rb', line 33

def indicator
  @indicator ||= '.'
end

#progress(override = nil) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/command_line_reporter/formatter/progress.rb', line 24

def progress(override = nil)
  str = override || self.indicator

  str = str.send(self.color) if self.color
  str = str.send('bold') if self.bold

  print str
end