class Dogsay::TextBox
Attributes
justify[R]
raw[R]
separator[R]
text_width[R]
Public Class Methods
new(text, opts={})
click to toggle source
# File lib/dogsay/text_box.rb, line 4 def initialize(text, opts={}) config = defaults.merge(opts) @text_width = config[:text_width] @separator = config[:strip] ? ' ' : / / @justify = config[:justify] @raw = raw_from(text) @ascii = ascii_from(text) end
Private Instance Methods
ascii_from(text)
click to toggle source
# File lib/dogsay/text_box.rb, line 15 def ascii_from(text) text.space_at(text_width - 4, on: separator) .wrap(text_width - 4) .boxed(text_width, justify: justify) end
defaults()
click to toggle source
# File lib/dogsay/text_box.rb, line 26 def defaults { text_width: 40, strip: false, justify: :center } end
raw_from(text)
click to toggle source
# File lib/dogsay/text_box.rb, line 21 def raw_from(text) max_width = text.split("\n").map(&:length).max text.boxed(max_width + 4, justify: :ljust) end