Class: DateIdea
- Inherits:
-
Object
- Object
- DateIdea
- Defined in:
- lib/date_idea.rb
Instance Method Summary collapse
- #attribute(name) ⇒ Object
- #attributes ⇒ Object
- #complete? ⇒ Boolean
-
#initialize(name = "") ⇒ DateIdea
constructor
A new instance of DateIdea.
- #kind(args) ⇒ Object
- #name ⇒ Object
- #outcome(score = nil) ⇒ Object
- #outcome_safe ⇒ Object
- #requirements ⇒ Object
- #requires(args) ⇒ Object
- #score ⇒ Object
- #stub? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name = "") ⇒ DateIdea
Returns a new instance of DateIdea.
3 4 5 6 7 8 |
# File 'lib/date_idea.rb', line 3 def initialize(name = "") @name = name.to_s @attributes = {} @requirements = {} @outcome = nil end |
Instance Method Details
#attribute(name) ⇒ Object
39 40 41 |
# File 'lib/date_idea.rb', line 39 def attribute(name) @attributes[name] end |
#attributes ⇒ Object
35 36 37 |
# File 'lib/date_idea.rb', line 35 def attributes @attributes end |
#complete? ⇒ Boolean
59 60 61 |
# File 'lib/date_idea.rb', line 59 def complete? not @outcome.nil? end |
#kind(args) ⇒ Object
10 11 12 13 14 |
# File 'lib/date_idea.rb', line 10 def kind(args) args.each do |field, value| @attributes[field] = value end end |
#name ⇒ Object
47 48 49 |
# File 'lib/date_idea.rb', line 47 def name @name end |
#outcome(score = nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/date_idea.rb', line 22 def outcome(score = nil) if score.nil? @outcome else @outcome = score end end |
#outcome_safe ⇒ Object
30 31 32 33 |
# File 'lib/date_idea.rb', line 30 def outcome_safe return @outcome unless @outcome.nil? -1 end |
#requirements ⇒ Object
43 44 45 |
# File 'lib/date_idea.rb', line 43 def requirements @requirements end |
#requires(args) ⇒ Object
16 17 18 19 20 |
# File 'lib/date_idea.rb', line 16 def requires(args) args.each do |field, value| @requirements[field] = value end end |
#score ⇒ Object
51 52 53 |
# File 'lib/date_idea.rb', line 51 def score @outcome end |
#stub? ⇒ Boolean
55 56 57 |
# File 'lib/date_idea.rb', line 55 def stub? @attributes.empty? end |
#to_s ⇒ Object
63 64 65 66 67 68 |
# File 'lib/date_idea.rb', line 63 def to_s attr_str = @attributes.map { |k,v| "#{k}: #{v}" }.join(", ") date_str = "#{@name}: (#{attr_str})" date_str = date_str + ", outcome: #{@outcome}" unless @outcome.nil? "#{date_str}\n" end |