Module: Putsplus
- Defined in:
- lib/putsplus.rb,
lib/putsplus/footer.rb,
lib/putsplus/version.rb
Defined Under Namespace
Classes: Footer
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
-
#full_linebr(char = '-') ⇒ Object
puts a full line break using the character provided.
-
#linebr(num = 6, char = '-') ⇒ Object
Puts a line break with given character and length.
-
#nputs(obj, prefix = nil) ⇒ Object
Puts only if obj is not null.
-
#tputs(*obj) ⇒ Object
Puts each parameter with a tab inbetween each.
-
#underline(string, char = '-') ⇒ Object
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.
Instance Method Details
#full_linebr(char = '-') ⇒ Object
puts a full line break using the character provided
Arguments:
char: the character to use. Defaults to '-'.
51 52 53 54 |
# 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 = '-') ⇒ Object
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 '-'
38 39 40 41 42 43 |
# 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) ⇒ Object
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
13 14 15 |
# File 'lib/putsplus.rb', line 13 def nputs obj, prefix = nil puts prefix.to_s + obj.to_s unless obj.nil? end |
#tputs(*obj) ⇒ Object
Puts each parameter with a tab inbetween each
21 22 23 24 25 26 27 28 29 |
# 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 = '-') ⇒ Object
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 '-'
62 63 64 65 |
# File 'lib/putsplus.rb', line 62 def underline string, char = '-' puts string linebr string.length, char end |