Created
February 4, 2016 12:54
-
-
Save jrochkind/e8ca8fae17eb3324d26d 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 Todos | |
attr_accessor :priority, :urgency, :title, :description | |
def initialize(priority = 1, urgency = 1) | |
@priority, @urgency = priority, urgency | |
raise ArgumentError, "urgency must be between 1 and 10" unless 1..10 === @urgency | |
raise ArgumentError, "priority must be between 1 and 10" unless 1..10 === @priority | |
end | |
def quadrant | |
@quadrant ||= | |
if important? && urgent? | |
1 | |
elsif important? && ! urgent? | |
2 | |
elsif !important? && !urgent? | |
3 | |
else | |
4 | |
end | |
end | |
end | |
def important? | |
6..10 === priority | |
end | |
def print_info | |
puts "priority -> #{@priority} - urgency -> #{@urgency} - quadrant -> #{@quadrant}" | |
end | |
def urgent? | |
6..10 === urgency | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment