Class: DiskStats::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/disk-stats.rb

Constant Summary collapse

LINE =
Regexp.new('(\d+)\ +(\d+)\ ([\w-]+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)\ (\d+)')

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ Device

Returns a new instance of Device.



10
11
12
13
14
# File 'lib/disk-stats.rb', line 10

def initialize line
  unless @line = LINE.match(line)
    raise DiskStats::ParseError.new("Error parsing line: #{line}")
  end
end

Instance Method Details

#inflightObject



27
# File 'lib/disk-stats.rb', line 27

def inflight; @line[12].to_i; end

#majorObject



16
# File 'lib/disk-stats.rb', line 16

def major; @line[1].to_i; end

#minorObject



17
# File 'lib/disk-stats.rb', line 17

def minor; @line[2].to_i; end

#nameObject



18
# File 'lib/disk-stats.rb', line 18

def name; @line[3]; end

#read_timeObject



22
# File 'lib/disk-stats.rb', line 22

def read_time; @line[7].to_i; end

#reads_completedObject



19
# File 'lib/disk-stats.rb', line 19

def reads_completed; @line[4].to_i; end

#reads_mergedObject



20
# File 'lib/disk-stats.rb', line 20

def reads_merged; @line[5].to_i; end

#sectors_readObject



21
# File 'lib/disk-stats.rb', line 21

def sectors_read; @line[6].to_i; end

#sectors_writtenObject



25
# File 'lib/disk-stats.rb', line 25

def sectors_written; @line[10].to_i; end

#total_timeObject



28
# File 'lib/disk-stats.rb', line 28

def total_time; @line[13].to_i; end

#weighted_timeObject



29
# File 'lib/disk-stats.rb', line 29

def weighted_time; @line[14].to_i; end

#write_timeObject



26
# File 'lib/disk-stats.rb', line 26

def write_time; @line[11].to_i; end

#writes_completedObject



23
# File 'lib/disk-stats.rb', line 23

def writes_completed; @line[8].to_i; end

#writes_mergedObject



24
# File 'lib/disk-stats.rb', line 24

def writes_merged; @line[9].to_i; end