Class: HoneyFormat::CLIResultWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/honey_format/cli/result_writer.rb

Overview

CLI result writer handles command output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verbose: false) ⇒ CLIResultWriter

Instantiate the result writer



12
13
14
# File 'lib/honey_format/cli/result_writer.rb', line 12

def initialize(verbose: false)
  @verbose = verbose
end

Instance Attribute Details

#verbosetrue, false

the writer mode



6
7
8
# File 'lib/honey_format/cli/result_writer.rb', line 6

def verbose
  @verbose
end

Instance Method Details

Print the string



25
26
27
28
29
# File 'lib/honey_format/cli/result_writer.rb', line 25

def print(string, verbose: false)
  return if !verbose? && verbose

  Kernel.print(string)
end

#puts(string, verbose: false) ⇒ Object

Puts the string



34
35
36
37
38
# File 'lib/honey_format/cli/result_writer.rb', line 34

def puts(string, verbose: false)
  return if !verbose? && verbose

  Kernel.puts(string)
end

#verbose?true, false

Return if verbose mode is true/false



18
19
20
# File 'lib/honey_format/cli/result_writer.rb', line 18

def verbose?
  @verbose
end