跳至内容 跳至搜索
方法
B
D
E
F
G
H
I
K
M
P
S
T
W
Z

常量

EXABYTE = PETABYTE * 1024
 
GIGABYTE = MEGABYTE * 1024
 
KILOBYTE = 1024
 
MEGABYTE = KILOBYTE * 1024
 
PETABYTE = TERABYTE * 1024
 
TERABYTE = GIGABYTE * 1024
 
ZETTABYTE = EXABYTE * 1024
 

实例公共方法

字节()

别名: bytes

字节()

启用字节计算和声明的使用,例如 45.bytes + 2.6.megabytes

2.bytes # => 2
也别名: byte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 15
def bytes
  self
end

()

别名: days

()

返回一个匹配指定天数的 Duration 实例。

2.days # => 2 days
也别名: day
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 37
def days
  ActiveSupport::Duration.days(self)
end

艾字节()

别名: exabytes

艾字节()

返回等同于指定艾字节的字节数。

2.exabytes # => 2_305_843_009_213_693_952
也别名: exabyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 63
def exabytes
  self * EXABYTE
end

两周()

别名: fortnights

两周()

返回一个匹配指定两周的 Duration 实例。

2.fortnights # => 4 weeks
也别名: fortnight
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 53
def fortnights
  ActiveSupport::Duration.weeks(self * 2)
end

吉字节()

别名: gigabytes

吉字节()

返回等同于指定吉字节的字节数。

2.gigabytes # => 2_147_483_648
也别名: gigabyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 39
def gigabytes
  self * GIGABYTE
end

小时()

别名: hours

小时()

返回一个匹配指定小时的 Duration 实例。

2.hours # => 2 hours
也别名: hour
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 29
def hours
  ActiveSupport::Duration.hours(self)
end

html_safe?()

# File activesupport/lib/active_support/core_ext/string/output_safety.rb, line 13
def html_safe?
  true
end

毫秒数()

返回等同于指定秒数的毫秒数。用于标准时间时长。

2.in_milliseconds # => 2000
1.hour.in_milliseconds # => 3600000
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 63
def in_milliseconds
  self * 1000
end

千字节()

别名: kilobytes

千字节()

返回等同于指定千字节的字节数。

2.kilobytes # => 2048
也别名: kilobyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 23
def kilobytes
  self * KILOBYTE
end

兆字节()

别名: megabytes

兆字节()

返回等同于指定兆字节的字节数。

2.megabytes # => 2_097_152
也别名: megabyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 31
def megabytes
  self * MEGABYTE
end

分钟()

别名: minutes

分钟()

返回一个匹配指定分钟的 Duration 实例。

2.minutes # => 2 minutes
也别名: minute
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 21
def minutes
  ActiveSupport::Duration.minutes(self)
end

拍字节()

别名: petabytes

拍字节()

返回等同于指定拍字节的字节数。

2.petabytes # => 2_251_799_813_685_248
也别名: petabyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 55
def petabytes
  self * PETABYTE
end

()

别名: seconds

()

返回一个匹配指定秒数的 Duration 实例。

2.seconds # => 2 seconds
也别名: second
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 13
def seconds
  ActiveSupport::Duration.seconds(self)
end

太字节()

别名: terabytes

太字节()

返回等同于指定太字节的字节数。

2.terabytes # => 2_199_023_255_552
也别名: terabyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 47
def terabytes
  self * TERABYTE
end

()

别名: weeks

()

返回一个匹配指定周数的 Duration 实例。

2.weeks # => 2 weeks
也别名: week
# File activesupport/lib/active_support/core_ext/numeric/time.rb, line 45
def weeks
  ActiveSupport::Duration.weeks(self)
end

泽字节()

别名: zettabytes

泽字节()

返回等同于指定泽字节的字节数。

2.zettabytes # => 2_361_183_241_434_822_606_848
也别名: zettabyte
# File activesupport/lib/active_support/core_ext/numeric/bytes.rb, line 71
def zettabytes
  self * ZETTABYTE
end