class AnyStyle::Page
Attributes
lines[RW]
width[RW]
Public Class Methods
new(lines = [], width: 0)
click to toggle source
# File lib/anystyle/page.rb 37 def initialize(lines = [], width: 0) 38 @lines = lines 39 @width = width 40 end
parse(lines, document)
click to toggle source
# File lib/anystyle/page.rb 6 def parse(lines, document) 7 pages, current, width = [], [], 0 8 9 lines.each do |line| 10 chars = display_chars(line.value) 11 document.line_counts[chars] += 1 12 document.nnum_counts[nnum(chars)] += 1 13 14 if page_break?(line.value) 15 unless current.empty? 16 pages << new(current, width: width) 17 end 18 19 current = [line] 20 width = chars.length 21 else 22 current << line 23 width = [width, chars.length].max 24 end 25 end 26 27 unless current.empty? 28 pages << new(current, width: width) 29 end 30 31 pages 32 end
Public Instance Methods
inspect()
click to toggle source
# File lib/anystyle/page.rb 46 def inspect 47 "#<AnyStyle::Page size={#{size}} width={#{width}}>" 48 end
size()
click to toggle source
# File lib/anystyle/page.rb 42 def size 43 lines.size 44 end