跳至内容 跳至搜索
方法
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
 

实例公共方法

byte()

别名:bytes

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

day()

别名:days

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

exabyte()

别名:exabytes

exabytes()

返回与提供的 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

fortnight()

别名:fortnights

fortnights()

返回与提供的 fortnight 数匹配的 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

gigabyte()

别名:gigabytes

gigabytes()

返回与提供的 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

hour()

别名:hours

hours()

返回与提供的 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

in_milliseconds()

返回与提供的秒数等效的毫秒数。与标准时间持续时间一起使用。

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

千字节()

别名:千字节

千字节()

返回与提供的千字节等效的字节数。

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

兆字节()

别名:兆字节

兆字节()

返回与提供的兆字节等效的字节数。

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

分钟()

别名:分钟

分钟()

返回与提供的分钟数匹配的持续时间实例。

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

拍字节()

别名:拍字节

拍字节()

返回与提供的拍字节等效的字节数。

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

()

别名:seconds

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

terabyte()

别名:terabytes

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

week()

别名:weeks

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

zettabyte()

别名:zettabytes

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