Skip to content

Instantly share code, notes, and snippets.

@bookis
Created September 8, 2014 15:45
Show Gist options
  • Save bookis/7827b59e18a016484457 to your computer and use it in GitHub Desktop.
Save bookis/7827b59e18a016484457 to your computer and use it in GitHub Desktop.
class Transaction
attr_accessor :amount, :success
def initialize(amount, success)
@amount = amount
@success = success
end
def success?
@success
end
def to_money
if success?
a = amount
a.to_f / 100
else
0
end
end
def self.credit(amount, success)
new(-amount, success)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment