abstract struct Number
Overview
The top-level number type.
Included Modules
- AliasMethod
- Comparable(BigFloat)
- Comparable(Number)
Direct Known Subclasses
Defined in:
crystal_on_steroids/bytes.crcrystal_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
-
#blank?
A number object will be blank if it's zero.
- #byte(*args)
-
#bytes
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
- #exabyte(*args)
-
#exabytes
Returns the number of bytes equivalent to the exabytes provided.
- #gigabyte(*args)
-
#gigabytes
Returns the number of bytes equivalent to the gigabytes provided.
- #kilobyte(*args)
-
#kilobytes
Returns the number of bytes equivalent to the kilobytes provided.
- #megabyte(*args)
-
#megabytes
Returns the number of bytes equivalent to the megabytes provided.
- #petabyte(*args)
-
#petabytes
Returns the number of bytes equivalent to the petabytes provided.
- #terabyte(*args)
-
#terabytes
Returns the number of bytes equivalent to the terabytes provided.
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
A number object will be blank if it's zero.
0.blank?
=> true
23.45.blank?
=> false
source: Rails ActiveSupport
Enables the use of byte calculations and declarations, like 45.bytes + 2.6.megabytes
2.bytes # => 2
Returns the number of bytes equivalent to the exabytes provided.
2.exabytes # => 2_305_843_009_213_693_952
Returns the number of bytes equivalent to the gigabytes provided.
2.gigabytes # => 2_147_483_648
Returns the number of bytes equivalent to the kilobytes provided.
2.kilobytes # => 2048
Returns the number of bytes equivalent to the megabytes provided.
2.megabytes # => 2_097_152
Returns the number of bytes equivalent to the petabytes provided.
2.petabytes # => 2_251_799_813_685_248
Returns the number of bytes equivalent to the terabytes provided.
2.terabytes # => 2_199_023_255_552