Skip to content

Instantly share code, notes, and snippets.

Created April 21, 2015 17:45
Show Gist options
  • Save anonymous/35e1bec295a156cf9166 to your computer and use it in GitHub Desktop.
Save anonymous/35e1bec295a156cf9166 to your computer and use it in GitHub Desktop.
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