Created
April 5, 2016 00:16
-
-
Save anonymous/da3b0863b2f0c8650f6befea27cf1593 to your computer and use it in GitHub Desktop.
Not mine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
value,label,key=false,preunit=false,postunit=false) | |
# takes a value and a label to be printed (using push_line) with useful optional parameters | |
# arguments = { | |
# hash_or_value: the thing to be printed can be a value itself or can be nested inside hash | |
# label: describes the value to be printed | |
# key: if hash_or_value is a hash, this parameter will point to the value inside the hash | |
# preunit: symbol that describes the value, placed BEFORE the value when printed | |
# postunit: symbol that describes the value, placed AFTER the value when printed | |
# } | |
if(hash_or_value.class == Hash) | |
fetch = hash_or_value.fetch(key,"No "+label) | |
else | |
fetch = hash_or_value | |
end | |
ret=fetch | |
if(fetch.class!=String) | |
fetch = fetch.to_s | |
end | |
if(preunit) | |
fetch=preunit+fetch | |
end | |
if(postunit) | |
fetch+=postunit | |
end | |
heading="\t#{label}:" | |
spacing="." * (25-heading.length) | |
push_line heading+spacing+fetch | |
return ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment