Sha256: aef01c909fa85217233f77be60e7e44d314323e75c3d2eebb2a9e3c540b6314d

Contents?: true

Size: 919 Bytes

Versions: 34

Compression:

Stored size: 919 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

# encoding=utf-8

# stdout manager
#
# module FOut
class FOut
  def initialize(config)
    @config = config
  end

  def approved_fout?(level)
    level <= fetch_display_level
  end

  # integer value for comparison
  #
  def fetch_display_level
    @config.fetch(:display_level, 1)
  end

  # integer value for comparison
  #
  def fetch_display_level_xbase_prefix
    @config.fetch(:level_xbase_prefix, '')
  end

  # standard output; not for debug
  #
  def fout(str)
    puts str
  end

  def fout_list(str)
    puts str
  end

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

  # display output at level or lower than filter (DISPLAY_LEVEL_DEFAULT)
  #
  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
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
markdown_exec-2.7.2 lib/fout.rb
markdown_exec-2.7.1 lib/fout.rb
markdown_exec-2.7.0 lib/fout.rb
markdown_exec-2.6.0 lib/fout.rb
markdown_exec-2.5.0 lib/fout.rb
markdown_exec-2.4.0 lib/fout.rb
markdown_exec-2.3.0 lib/fout.rb
markdown_exec-2.2.0 lib/fout.rb
markdown_exec-2.1.0 lib/fout.rb
markdown_exec-2.0.8.4 lib/fout.rb
markdown_exec-2.0.8.3 lib/fout.rb
markdown_exec-2.0.8.2 lib/fout.rb
markdown_exec-2.0.8.1 lib/fout.rb
markdown_exec-2.0.8 lib/fout.rb
markdown_exec-2.0.7 lib/fout.rb
markdown_exec-2.0.6 lib/fout.rb
markdown_exec-2.0.5 lib/fout.rb
markdown_exec-2.0.4 lib/fout.rb
markdown_exec-2.0.3.2 lib/fout.rb
markdown_exec-2.0.3.1 lib/fout.rb