Class: VER::Status::Percent

Inherits:
Position show all
Defined in:
lib/ver/status/percent.rb

Instance Attribute Summary

Attributes inherited from Label

#column, #format, #row, #status, #sticky, #variable, #weight

Instance Method Summary collapse

Methods inherited from Position

#setup

Methods inherited from Label

#buffer, #destroyed?, #initialize, #on_destroy, #register, #setup, #style=, #update

Methods included from LabelToggle

#toggle

Constructor Details

This class inherits a constructor from VER::Status::Label

Instance Method Details

#to_sObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ver/status/percent.rb', line 4

def to_s
  here = buffer.count(1.0, :insert, :lines)
  total = buffer.count(1.0, :end, :lines)
  percent = ((100.0 / total) * here).round

  case percent
  when 100, 99; 'Bot'
  when 0      ; 'Top'
  else        ; '%2d%%' % percent
  end
end