Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-measurement/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#to_measurementObject



4
5
6
# File 'lib/ruby-measurement/core_ext/string.rb', line 4

def to_measurement
  Measurement.parse(self)
end

#to_unitObject



8
9
10
# File 'lib/ruby-measurement/core_ext/string.rb', line 8

def to_unit
  Measurement::Unit[self] or raise ArgumentError, "Invalid unit: '#{self}'"
end