Class: Roma::Mkconfig::Box

Inherits:
Object
  • Object
show all
Defined in:
lib/roma/tools/mkconfig.rb

Class Method Summary collapse

Class Method Details



240
241
242
243
244
# File 'lib/roma/tools/mkconfig.rb', line 240

def self.print_edge(width)
  print "+"
    width.times { print "-" }
  print "+\n"
end


246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/roma/tools/mkconfig.rb', line 246

def self.print_with_box(arg)
  return if arg.count == 0

  if arg.class == Hash
    strs = Array.new
    arg.each do |k, v|
       strs << "#{k}: #{arg[k]}"
    end
    arg = strs
  end

  width = max_length(arg) + 1
  print_edge(width)

  arg.each do |s|
    print "|#{s}"
    (width - s.length).times do
      print " "
    end
    print "|\n"
  end

  print_edge(width)
end