# File ../../../../../lib/review/book/volume.rb, line 12 def self.count_file(path) b = c = l = 0 File.foreach(path) do |line| next if /\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 28 def self.dummy new(-1, -1, -1) end
# File ../../../../../lib/review/book/volume.rb, line 32 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 24 def self.sum(vols) vols.inject(new) { |sum, i| sum + i } end
# File ../../../../../lib/review/book/volume.rb, line 56 def +(other) Volume.new(@bytes + other.bytes, @chars + other.chars, @lines + other.lines) end
# File ../../../../../lib/review/book/volume.rb, line 44 def kbytes (@bytes.to_f / 1024).ceil end
# File ../../../../../lib/review/book/volume.rb, line 48 def page (kbytes.to_f / @page_per_kbyte).ceil end
# File ../../../../../lib/review/book/volume.rb, line 52 def to_s "#{kbytes}KB #{@chars}C #{@lines}L #{page}P" end