Method: String#to_u

Defined in:
opal/browser/css/unit.rb

#to_uObject

[View source]

169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'opal/browser/css/unit.rb', line 169

def to_u
  if matches = self.match(/^([\d+.]+)(.+)?$/)
    value = matches[1].to_f

    if unit = matches[2]
      value.__send__(unit.downcase)
    else
      value
    end
  else
    0
  end
end