Module: FVMUtil

Included in:
Architect::Report
Defined in:
lib/foreman_vm/util.rb

Overview

Miscellaneous utility functions

Instance Method Summary collapse

Instance Method Details

#gigabytes(s) ⇒ Object

Given an amount in bytes, return the human-readable version in GiB



9
10
11
12
13
14
15
16
17
# File 'lib/foreman_vm/util.rb', line 9

def gigabytes(s)
  if s.to_i < 1073741824
    mb = s.to_f / 1024 / 1024
    sprintf '%0.0f MiB', mb
  else
    gb = s.to_f / 1024 / 1024 / 1024
    sprintf '%0.0f GiB', gb
  end
end

#shortname(fqdn) ⇒ Object

Given an FQDN, return the shortname



4
5
6
# File 'lib/foreman_vm/util.rb', line 4

def shortname(fqdn)
  fqdn.sub(/\..*/, '') 
end