module Facter::Util::Aix::InfoExtractor

Constants

GIGABYTES_EXPONENT
MEGABYTES_EXPONENT
PROPERTIES

Public Class Methods

extract(content, cmd) click to toggle source
# File lib/facter/util/aix/info_extractor.rb, line 59
def self.extract(content, cmd)
  property_hash = {}
  properties = PROPERTIES[cmd]
  properties.each do |property|
    str = (properties - [property]).join('|')
    matcher = content.match(/(?:^|^[^:]+:[^:]+)#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
    if matcher
      value = matcher[1].strip
      property_hash[property.split(':').first] = value
    end
  end
  property_hash
end