Class: PrettyPrint
- Inherits:
-
Object
- Object
- PrettyPrint
- Defined in:
- lib/pretty-printing.rb
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(quote, length) ⇒ PrettyPrint
constructor
A new instance of PrettyPrint.
Constructor Details
#initialize(quote, length) ⇒ PrettyPrint
Returns a new instance of PrettyPrint.
2 3 4 5 6 |
# File 'lib/pretty-printing.rb', line 2 def initialize(quote,length) @quote = quote @length = length @arr = @quote.split(" ") end |
Instance Method Details
#format ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/pretty-printing.rb', line 8 def format q = [] i = 0 while i < @arr.length q << " | #{@arr[i..i+@length].join(" ")}" i += @length+1 end @quote = q.join("\n") end |