Class: FOut
Overview
stdout manager
module FOut
Instance Method Summary collapse
- #approved_fout?(level) ⇒ Boolean
-
#fetch_display_level ⇒ Object
integer value for comparison.
-
#fetch_display_level_xbase_prefix ⇒ Object
integer value for comparison.
-
#fout(str) ⇒ Object
standard output; not for debug.
- #fout_list(str) ⇒ Object
- #fout_section(name, data) ⇒ Object
-
#initialize(config) ⇒ FOut
constructor
A new instance of FOut.
-
#lout(str, level: DISPLAY_LEVEL_BASE) ⇒ Object
display output at level or lower than filter (DISPLAY_LEVEL_DEFAULT).
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
14 15 16 |
# File 'lib/fout.rb', line 14 def approved_fout?(level) level <= fetch_display_level end |
#fetch_display_level ⇒ Object
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_prefix ⇒ Object
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 |