Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/numeric_with_unit/core_ext.rb
Instance Method Summary collapse
Instance Method Details
#to_nwu(mthd = :to_r) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/numeric_with_unit/core_ext.rb', line 24 def to_nwu(mthd=:to_r) # TODO: 適当なのでもう少しいい感じに。いい感じに m = self.match /.*?(?=[\s\(\[])/ value = m.to_s unit = m.post_match.strip.gsub(/^\[|\]$/, '') NumericWithUnit.new(value.__send__(mthd), unit) end |