Created
September 8, 2014 15:45
-
-
Save bookis/7827b59e18a016484457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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