module Putsplus
Constants
- VERSION
Public Instance Methods
full_linebr(char = '-')
click to toggle source
puts a full line break using the character provided
Arguments:
char: the character to use. Defaults to '-'.
# File lib/putsplus.rb, line 51 def full_linebr char = '-' raise Exeception, "char must be one character only" unless char.to_s.length == 1 linebr `tput cols`, char end
linebr(num = 6, char = '-')
click to toggle source
Puts a line break with given character and length
Arguments:
num: number of times to repeat the given character. Default is 6. char: the character or string to repeat. Default is '-'
# File lib/putsplus.rb, line 38 def linebr num = 6, char = '-' raise Exeception, "num must be an Integer" unless is_int?(num) raise Exeception, "char must be an Character or String" unless (is_string? char) puts char.to_s * num.to_i end
nputs(obj, prefix = nil)
click to toggle source
Puts only if obj is not null
Arguments: obj: the obj that will be puts if it isn't null prefix: obj to append to the puts if obj isn't null
# File lib/putsplus.rb, line 13 def nputs obj, prefix = nil puts prefix.to_s + obj.to_s unless obj.nil? end
tputs(*obj)
click to toggle source
Puts each parameter with a tab inbetween each
# File lib/putsplus.rb, line 21 def tputs *obj out = "" obj.each_with_index do |o, index| s = o.to_s s += "\t" unless index == obj.size - 1 out << s end puts out end
underline(string, char = '-')
click to toggle source
Puts the string given and then underlines it with the character provided Arguments:
String: the string to puts Char: the char used to underline the string. Defaults to '-'
# File lib/putsplus.rb, line 62 def underline string, char = '-' puts string linebr string.length, char end
Private Instance Methods
is_int?(obj)
click to toggle source
PRIVATE VARS
# File lib/putsplus.rb, line 71 def is_int? obj true if Integer(obj) rescue false end
is_string?(obj)
click to toggle source
# File lib/putsplus.rb, line 75 def is_string? obj true if String(obj) rescue false end