I'm using inside Bash Scripts that code to structure the output in sections:
box_full() {
printf '*%.0s' $(seq 1 67)
echo ""
}
box_content() {
echo -n "*"
if [ $# -eq 0 ]
then
printf ' %.0s' $(seq 1 65)
elif [ $# -eq 1 ]
then
RIGHT="$1"
printf ' %.0s' $(seq 1 17)
echo -n "${RIGHT}"
printf ' %.0s' $(seq 1 $[48-${#RIGHT}])
elif [ $# -eq 2 ]
then
LEFT="$1"
RIGHT="$2"
printf ' %.0s' $(seq 1 3)
echo -n "${LEFT}"
printf ' %.0s' $(seq 1 $[14-${#LEFT}])
echo -n "${RIGHT}"
printf ' %.0s' $(seq 1 $[48-${#RIGHT}])
fi
echo "*"
}`
The usage was:
box_full
box_content "Download-Process..."
box_full`
Is there any way to do this in Ruby Scripts?
EDIT: The first one i have solved through:
module Style
def self.box_full
puts '*' * 67
end
def self.box_content(content)
box_rest = 66 - content.length
box_rest.to_i
print '* ' + box_rest * '' + '*'
end
end
So box full works good.
For the second one i want to give a string called content to the method box content. Actually it doesn't work. The wished output is:
* content *
The last * should be set on the end of the line on place 67. Is it possible to solve that in Ruby?