Module: FancyIrb::SizeDetector
- Extended by:
- SizeDetector
- Included in:
- FancyIrb, SizeDetector
- Defined in:
- lib/fancy_irb/size_detector.rb
Instance Method Summary collapse
Instance Method Details
#height_of(data, width) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/fancy_irb/size_detector.rb', line 9 def height_of(data, width) data = data.to_s long_lines = data.split("\n").inject(0){ |sum, line| sum + width_of(line) / (width + 1) } data.count("\n") + long_lines end |
#width_of(data) ⇒ Object
5 6 7 |
# File 'lib/fancy_irb/size_detector.rb', line 5 def width_of(data) Unicode::DisplayWidth.of(Paint.unpaint(data.to_s)) end |