Class: Facter::Util::Facts::UnitConverter
- Inherits:
 - 
      Object
      
        
- Object
 - Facter::Util::Facts::UnitConverter
 
 
- Defined in:
 - lib/facter/util/facts/unit_converter.rb
 
Class Method Summary collapse
- .bytes_to_human_readable(bytes) ⇒ Object
 - .bytes_to_mb(value_in_bytes) ⇒ Object
 - .hertz_to_human_readable(speed) ⇒ Object
 
Class Method Details
.bytes_to_human_readable(bytes) ⇒ Object
      25 26 27 28 29 30 31 32  | 
    
      # File 'lib/facter/util/facts/unit_converter.rb', line 25 def bytes_to_human_readable(bytes) return unless bytes return "#{bytes} bytes" if bytes < 1024 number, multiple = determine_exponent(bytes) "#{pad_number(number)} #{multiple}" end  | 
  
.bytes_to_mb(value_in_bytes) ⇒ Object
      8 9 10 11 12 13 14  | 
    
      # File 'lib/facter/util/facts/unit_converter.rb', line 8 def bytes_to_mb(value_in_bytes) return unless value_in_bytes value_in_bytes = value_in_bytes.to_i (value_in_bytes / (1024.0 * 1024.0)) end  | 
  
.hertz_to_human_readable(speed) ⇒ Object
      16 17 18 19 20 21 22 23  | 
    
      # File 'lib/facter/util/facts/unit_converter.rb', line 16 def hertz_to_human_readable(speed) speed = speed.to_i return if !speed || speed.zero? validated_speed, metric_prefix = determine_metric_prefix(speed) "#{format('%<displayed_speed>.2f', displayed_speed: validated_speed.round(2))} #{metric_prefix}Hz" end  |