Module: Kontena::Cli::BytesHelper
- Included in:
- Nodes::ShowCommand
- Defined in:
- lib/kontena/cli/bytes_helper.rb
Constant Summary collapse
Instance Method Summary collapse
- #to_gigabytes(bytes, ndigits = nil) ⇒ Object
- #to_kilobytes(bytes, ndigits = nil) ⇒ Object
- #to_megabytes(bytes, ndigits = nil) ⇒ Object
- #to_terabytes(bytes, ndigits) ⇒ Object
Instance Method Details
#to_gigabytes(bytes, ndigits = nil) ⇒ Object
20 21 22 23 |
# File 'lib/kontena/cli/bytes_helper.rb', line 20 def to_gigabytes(bytes, ndigits=nil) return 0.0 if bytes.nil? round(bytes.to_f / GIGABYTE, ndigits) end |
#to_kilobytes(bytes, ndigits = nil) ⇒ Object
10 11 12 13 |
# File 'lib/kontena/cli/bytes_helper.rb', line 10 def to_kilobytes(bytes, ndigits=nil) return 0.0 if bytes.nil? round(bytes.to_f / KILOBYTE, ndigits) end |
#to_megabytes(bytes, ndigits = nil) ⇒ Object
15 16 17 18 |
# File 'lib/kontena/cli/bytes_helper.rb', line 15 def to_megabytes(bytes, ndigits=nil) return 0.0 if bytes.nil? round(bytes.to_f / MEGABYTE, ndigits) end |
#to_terabytes(bytes, ndigits) ⇒ Object
25 26 27 28 |
# File 'lib/kontena/cli/bytes_helper.rb', line 25 def to_terabytes(bytes, ndigits) return 0.0 if bytes.nil? round(bytes.to_f / TERABYTE, ndigits) end |