Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
Instance Method Details
#to_size ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/core_ext/string.rb', line 8 def to_size amount,unit = self.split(" ") if amount and unit case unit.downcase when "bytes","b","by" amount.to_i when "mb","megabytes","mbs","m","mi","mo" (amount.to_f * 1024).to_i when "gb","gigabytes","gbs","g","gi" (amount.to_f * 1024 * 1024).to_i else nil end else nil end end |
#to_time ⇒ Object
4 5 6 |
# File 'lib/core_ext/string.rb', line 4 def to_time Chronic.parse(self) end |