Class: FOut

Inherits:
Object show all
Defined in:
lib/fout.rb

Overview

stdout manager

module FOut

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ FOut

Returns a new instance of FOut.



10
11
12
# File 'lib/fout.rb', line 10

def initialize(config)
  @config = config
end

Instance Method Details

#approved_fout?(level) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/fout.rb', line 14

def approved_fout?(level)
  level <= fetch_display_level
end

#fetch_display_levelObject

integer value for comparison



20
21
22
# File 'lib/fout.rb', line 20

def fetch_display_level
  @config.fetch(:display_level, 1)
end

#fetch_display_level_xbase_prefixObject

integer value for comparison



26
27
28
# File 'lib/fout.rb', line 26

def fetch_display_level_xbase_prefix
  @config.fetch(:level_xbase_prefix, '')
end

#fout(str) ⇒ Object

standard output; not for debug



32
33
34
# File 'lib/fout.rb', line 32

def fout(str)
  puts str
end

#fout_list(str) ⇒ Object



36
37
38
# File 'lib/fout.rb', line 36

def fout_list(str)
  puts str
end

#fout_section(name, data) ⇒ Object



40
41
42
43
# File 'lib/fout.rb', line 40

def fout_section(name, data)
  puts "# #{name}"
  puts data.to_yaml
end

#lout(str, level: DISPLAY_LEVEL_BASE) ⇒ Object

display output at level or lower than filter (DISPLAY_LEVEL_DEFAULT)



47
48
49
50
51
# File 'lib/fout.rb', line 47

def lout(str, level: DISPLAY_LEVEL_BASE)
  return unless approved_fout?(level)

  fout level == DISPLAY_LEVEL_BASE ? str : fetch_display_level_xbase_prefix + str
end