Class: Capybara::UI::StringValue::Money
- Inherits:
-
Object
- Object
- Capybara::UI::StringValue::Money
- Extended by:
- Forwardable
- Defined in:
- lib/capybara/ui/widgets/string_value.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ Money
constructor
A new instance of Money.
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 |