class RBT::SimplifyRootEntries

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::SimplifyRootEntries[]

#
# File lib/rbt/utility_scripts/simplify_root_entries.rb, line 83
def self.[](i = ARGV)
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/simplify_root_entries.rb, line 27
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/simplify_root_entries.rb, line 41
def reset
  super()
  infer_the_namespace
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/simplify_root_entries.rb, line 76
def run
  work_on_input_file
end
work_on_input_file() click to toggle source
#

work_on_input_file

#
# File lib/rbt/utility_scripts/simplify_root_entries.rb, line 49
def work_on_input_file
  _ = first_argument?
  if _ and File.file?(_)
    save_the_file = false
    dataset = File.readlines(_)
    index = 0
    dataset.map! {|line| index += 1
      if line.include? 'root:root'
        save_the_file = true
        line.gsub!(/root:root/, '0:0')
        opne "At line #{steelblue(index)} a root:root entry "\
             "has been replaced with 0:0."
      end
      line
    }
    if save_the_file
      into = _
      opne "Now saving the modified dataset into `#{sfile(into)}`."
      what = dataset.join
      write_what_into(what, into)
    end
  end
end