Module: Lumos::Formatters::BaseChopper
- Included in:
- Base
- Defined in:
- lib/lumos/formatters/base_chopper.rb
Instance Method Summary collapse
- #chopped_message ⇒ Object
- #chopped_message_length ⇒ Object
- #chopping_last_line?(line) ⇒ Boolean
- #chopping_line(line) ⇒ Object
- #chopping_padding(line) ⇒ Object
- #iterate_chopped_lines(string = "") ⇒ Object
Instance Method Details
#chopped_message ⇒ Object
4 5 6 |
# File 'lib/lumos/formatters/base_chopper.rb', line 4 def .scan(/.{1,#{( length > ? : length )}}/) end |
#chopped_message_length ⇒ Object
8 9 10 |
# File 'lib/lumos/formatters/base_chopper.rb', line 8 def [0].size end |
#chopping_last_line?(line) ⇒ Boolean
21 22 23 |
# File 'lib/lumos/formatters/base_chopper.rb', line 21 def chopping_last_line?(line) .index(line) == .size - 1 end |
#chopping_line(line) ⇒ Object
17 18 19 |
# File 'lib/lumos/formatters/base_chopper.rb', line 17 def chopping_line(line) "\n" if .size > 1 && !chopping_last_line?(line) end |
#chopping_padding(line) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/lumos/formatters/base_chopper.rb', line 25 def chopping_padding(line) if chopping_last_line?(line) first_line = .first.size last_line = .last.size " " * (first_line - last_line) if first_line > last_line end end |
#iterate_chopped_lines(string = "") ⇒ Object
12 13 14 15 |
# File 'lib/lumos/formatters/base_chopper.rb', line 12 def iterate_chopped_lines(string = "") .each{ |line| string += yield line } string end |