Object
# File lib/reckon/money.rb, line 44 def Money::from_s( value, options = {} ) return nil if value.empty? value = value.gsub(/\./, '').gsub(/,/, '.') if options[:comma_separates_cents] amount = value.gsub(/[^\d\.]/, '').to_f amount *= -1 if value =~ /[\(\-]/ Money.new( amount, options ) end
# File lib/reckon/money.rb, line 52 def Money::likelihood( entry ) money_score = 0 money_score += 20 if entry[/^[\-\+\(]{0,2}\$/] money_score += 10 if entry[/^\$?\-?\$?\d+[\.,\d]*?[\.,]\d\d$/] money_score += 10 if entry[/\d+[\.,\d]*?[\.,]\d\d$/] money_score += entry.gsub(/[^\d\.\-\+,\(\)]/, '').length if entry.length < 7 money_score -= entry.length if entry.length > 8 money_score -= 20 if entry !~ /^[\$\+\.\-,\d\(\)]+$/ money_score end
# File lib/reckon/money.rb, line 21 def -@ Money.new( -@amount, :currency => @currency, :suffixed => @suffixed ) end
# File lib/reckon/money.rb, line 25 def <=>( mon ) other_amount = mon.to_f if @amount < other_amount -1 elsif @amount > other_amount 1 else 0 end end
# File lib/reckon/money.rb, line 36 def pretty( negate = false ) if @suffixed (@amount >= 0 ? " " : "") + sprintf("%0.2f #{@currency}", @amount * (negate ? -1 : 1)) else (@amount >= 0 ? " " : "") + sprintf("%0.2f", @amount * (negate ? -1 : 1)).gsub(/^((\-)|)(?=\d)/, "\\1#{@currency}") end end
Generated with the Darkfish Rdoc Generator 2.