Class: Memstat::Proc::Smaps::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/memstat/proc/smaps.rb

Overview

Memstat::Proc::Smaps::Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeItem

Returns a new instance of Item.



88
89
90
91
92
# File 'lib/memstat/proc/smaps.rb', line 88

def initialize
  FIELDS.each do |field|
    send("#{field}=", 0)
  end
end

Instance Attribute Details

#address_endObject (readonly)

Returns the value of attribute address_end.



80
81
82
# File 'lib/memstat/proc/smaps.rb', line 80

def address_end
  @address_end
end

#address_startObject (readonly)

Returns the value of attribute address_start.



79
80
81
# File 'lib/memstat/proc/smaps.rb', line 79

def address_start
  @address_start
end

#device_majorObject (readonly)

Returns the value of attribute device_major.



83
84
85
# File 'lib/memstat/proc/smaps.rb', line 83

def device_major
  @device_major
end

#device_minorObject (readonly)

Returns the value of attribute device_minor.



84
85
86
# File 'lib/memstat/proc/smaps.rb', line 84

def device_minor
  @device_minor
end

#inodeObject (readonly)

Returns the value of attribute inode.



85
86
87
# File 'lib/memstat/proc/smaps.rb', line 85

def inode
  @inode
end

#offsetObject (readonly)

Returns the value of attribute offset.



82
83
84
# File 'lib/memstat/proc/smaps.rb', line 82

def offset
  @offset
end

#permsObject (readonly)

Returns the value of attribute perms.



81
82
83
# File 'lib/memstat/proc/smaps.rb', line 81

def perms
  @perms
end

#regionObject (readonly)

Returns the value of attribute region.



86
87
88
# File 'lib/memstat/proc/smaps.rb', line 86

def region
  @region
end

Instance Method Details

#parse_field_line(line) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/memstat/proc/smaps.rb', line 104

def parse_field_line(line)
  parts = line.strip.split
  field = parts[0].downcase.sub(':','')
  return if field == 'vmflags'
  value = Integer(parts[1]) * 1024
  send("#{field}=", value) if respond_to? "#{field}="
end

#parse_first_line(line) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/memstat/proc/smaps.rb', line 94

def parse_first_line(line)
  parts = line.strip.split
  @address_start, @address_end = parts[0].split('-')
  @perms = parts[1]
  @offset = parts[2]
  @device_major, @device_minor = parts[3].split(':')
  @inode = parts[4]
  @region = parts[5] || 'anonymous'
end