class ReVIEW::Book::Volume
Attributes
bytes[R]
chars[R]
lines[RW]
page_per_kbyte[RW]
Public Class Methods
count_file(path)
click to toggle source
# 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.size l += 1 end new(b, c, l) end
dummy()
click to toggle source
# File lib/review/book/volume.rb, line 28 def self.dummy new(-1, -1, -1) end
new(bytes = 0, chars = 0, lines = 0)
click to toggle source
# 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
sum(vols)
click to toggle source
# File lib/review/book/volume.rb, line 24 def self.sum(vols) vols.inject(new) { |sum, i| sum + i } end
Public Instance Methods
+(other)
click to toggle source
# File lib/review/book/volume.rb, line 56 def +(other) Volume.new(@bytes + other.bytes, @chars + other.chars, @lines + other.lines) end
kbytes()
click to toggle source
# File lib/review/book/volume.rb, line 44 def kbytes (@bytes.to_f / 1024).ceil end
page()
click to toggle source
# File lib/review/book/volume.rb, line 48 def page (kbytes.to_f / @page_per_kbyte).ceil end
to_s()
click to toggle source
# File lib/review/book/volume.rb, line 52 def to_s "#{kbytes}KB #{@chars}C #{@lines}L #{page}P" end