abstract struct Number

Overview

The top-level number type.

Included Modules

Direct Known Subclasses

Defined in:

crystal_on_steroids/bytes.cr
crystal_on_steroids/number.cr

Constant Summary

EXABYTE = PETABYTE * 1024
GIGABYTE = MEGABYTE * 1024
KILOBYTE = 1024.to_big_i
MEGABYTE = KILOBYTE * 1024
PETABYTE = TERABYTE * 1024
TERABYTE = GIGABYTE * 1024

Instance Method Summary

Instance methods inherited from class Object

in?(another_object) in?, presence presence, presence_in(another_object) presence_in, present? present?, to_param to_param, to_query(namespace)
to_query
to_query

Class methods inherited from class Object

❨╯°□°❩╯︵┻━┻ ❨╯°□°❩╯︵┻━┻

Instance Method Detail

def blank? #

A number object will be blank if it's zero.

0.blank?
=> true

23.45.blank?
=> false

source: Rails ActiveSupport


[View source]
def byte(*args) #

[View source]
def bytes #

Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes

  2.bytes # => 2

[View source]
def exabyte(*args) #

[View source]
def exabytes #

Returns the number of bytes equivalent to the exabytes provided.

  2.exabytes # => 2_305_843_009_213_693_952

[View source]
def gigabyte(*args) #

[View source]
def gigabytes #

Returns the number of bytes equivalent to the gigabytes provided.

  2.gigabytes # => 2_147_483_648

[View source]
def kilobyte(*args) #

[View source]
def kilobytes #

Returns the number of bytes equivalent to the kilobytes provided.

  2.kilobytes # => 2048

[View source]
def megabyte(*args) #

[View source]
def megabytes #

Returns the number of bytes equivalent to the megabytes provided.

  2.megabytes # => 2_097_152

[View source]
def petabyte(*args) #

[View source]
def petabytes #

Returns the number of bytes equivalent to the petabytes provided.

  2.petabytes # => 2_251_799_813_685_248

[View source]
def terabyte(*args) #

[View source]
def terabytes #

Returns the number of bytes equivalent to the terabytes provided.

  2.terabytes # => 2_199_023_255_552

[View source]