Class: Capybara::UI::StringValue::Money

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capybara/ui/widgets/string_value.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Money

Returns a new instance of Money.


24
25
26
27
28
29
# File 'lib/capybara/ui/widgets/string_value.rb', line 24

def initialize(str)
  fail ArgumentError, "can't convert `#{str}` to money" \
    unless str =~ /^-?\$\d+(?:,\d{3})*(?:\.\d+)?/

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