Module: CDK::Justifications
- Included in:
- CDKOBJS
- Defined in:
- lib/cdk/mixins/justifications.rb
Instance Method Summary collapse
-
#justify_string(box_width, mesg_length, justify) ⇒ Object
This takes a string, a field width, and a justification type and returns the adjustment to make, to fill the justification requirement.
Instance Method Details
#justify_string(box_width, mesg_length, justify) ⇒ Object
This takes a string, a field width, and a justification type and returns the adjustment to make, to fill the justification requirement
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cdk/mixins/justifications.rb', line 6 def justify_string (box_width, mesg_length, justify) # make sure the message isn't longer than the width # if it is, return 0 if mesg_length >= box_width return 0 end # try to justify the message case justify when LEFT 0 when RIGHT box_width - mesg_length when CENTER (box_width - mesg_length) / 2 else justify end end |