# File lib/review/book/volume.rb, line 15 def Volume.count_file(path) b = c = l = 0 File.foreach(path) do |line| next if %r<\A\#@> =~ line text = line.gsub(/\s+/, '') b += text.bytesize c += text.charsize l += 1 end new(b, c, l) end
# File lib/review/book/volume.rb, line 31 def Volume.dummy new(-1, -1, -1) end
# File lib/review/book/volume.rb, line 35 def initialize(bytes = 0, chars = 0, lines = 0) @bytes = bytes @chars = chars @lines = lines @page_per_kbyte = nil end
# File lib/review/book/volume.rb, line 27 def Volume.sum(vols) vols.inject(new()) {|sum, i| sum + i } end
# File lib/review/book/volume.rb, line 59 def +(other) Volume.new(@bytes + other.bytes, @chars + other.chars, @lines + other.lines) end
# File lib/review/book/volume.rb, line 47 def kbytes (@bytes.to_f / 1024).ceil end
# File lib/review/book/volume.rb, line 51 def page (kbytes.to_f/@page_per_kbyte).ceil end
# File lib/review/book/volume.rb, line 55 def to_s "#{kbytes()}KB #{@chars}C #{@lines}L #{page()}P" end