/orange_tree.rb Secret
Created
August 31, 2014 09:08
-
Star
(0)
You must be signed in to star a gist -
Fork
(165)
You must be signed in to fork a gist
-
-
Save nextacademy-private/3cbcbc576c9b2eb85792 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # This is how you define your own custom exception classes | |
| class NoOrangesError < StandardError | |
| end | |
| class OrangeTree | |
| # Ages the tree one year | |
| def age! | |
| end | |
| # Returns +true+ if there are any oranges on the tree, +false+ otherwise | |
| def any_oranges? | |
| end | |
| # Returns an Orange if there are any | |
| # Raises a NoOrangesError otherwise | |
| def pick_an_orange! | |
| raise NoOrangesError, "This tree has no oranges" unless self.any_oranges? | |
| # orange-picking logic goes here | |
| end | |
| end | |
| class Orange | |
| # Initializes a new Orange with diameter +diameter+ | |
| def initialize(diameter) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment