Class: DateIdea

Inherits:
Object
  • Object
show all
Defined in:
lib/date_idea.rb

Instance Method Summary collapse

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

#attributesObject



35
36
37
# File 'lib/date_idea.rb', line 35

def attributes
  @attributes
end

#complete?Boolean

Returns:

  • (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

#nameObject



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_safeObject



30
31
32
33
# File 'lib/date_idea.rb', line 30

def outcome_safe
  return @outcome unless @outcome.nil?
  -1
end

#requirementsObject



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

#scoreObject



51
52
53
# File 'lib/date_idea.rb', line 51

def score
  @outcome
end

#stub?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/date_idea.rb', line 55

def stub?
  @attributes.empty?
end

#to_sObject



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