class Dill::StringValue::Money

Attributes

str[R]

Public Class Methods

new(str) click to toggle source
# File lib/dill/widgets/string_value.rb, line 23
def initialize(str)
  fail ArgumentError, "can't convert `#{str}` to money" \
    unless str =~ /^-?\$\d+(?:,\d{3})*(?:\.\d+)?/

  @str = (str =~ /^-/ ? '-' : '') + str.gsub(/^-?\$|,/, '')
end