Created
April 21, 2015 17:45
-
-
Save anonymous/35e1bec295a156cf9166 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 BookInStock | |
attr_reader :isbn | |
attr_accessor :price | |
def initialize(isbn, price) | |
@isbn = isbn | |
@price = Float(price) | |
end | |
def price_in_cents | |
Integer(price*100 + 0.5) | |
end | |
def price_in_cents=(cents) | |
@price = cents / 100.0 | |
end | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment