Class: Df
- Inherits:
-
Object
- Object
- Df
- Defined in:
- lib/Linux/df.rb
Instance Attribute Summary collapse
-
#system ⇒ Object
writeonly
Sets the attribute system.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(string = nil, system = nil) ⇒ Df
constructor
A new instance of Df.
- #parse(string) ⇒ Object
Constructor Details
#initialize(string = nil, system = nil) ⇒ Df
Returns a new instance of Df.
9 10 11 12 13 14 15 |
# File 'lib/Linux/df.rb', line 9 def initialize(string = nil, system = nil) @system = system @table = {} parse(string) unless string.nil? end |
Instance Attribute Details
#system=(value) ⇒ Object (writeonly)
Sets the attribute system
7 8 9 |
# File 'lib/Linux/df.rb', line 7 def system=(value) @system = value end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'lib/Linux/df.rb', line 5 def table @table end |
Instance Method Details
#parse(string) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/Linux/df.rb', line 17 def parse(string) string.each_line do |s| next if s =~ /^\s*Filesystem\s+Size\s+Used\s+Avail\s+Use\%\s+Mounted\s+on\s*$/ next if s =~ /^\s*Filesystem\s+1024\-blocks\s+Used\s+Available\s+Capacity\s+Mounted\s+on\s*$/ entry = Df_entry.new(s, @system) @table[entry.mounted_on] = entry end end |