summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/action_file_executor.rb3
-rw-r--r--lib/family_tree.rb6
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/action_file_executor.rb b/lib/action_file_executor.rb
index 2354dd7..701ad02 100644
--- a/lib/action_file_executor.rb
+++ b/lib/action_file_executor.rb
@@ -72,7 +72,8 @@ class ActionFileExecutor
when 'ADD_CHILD'
puts FamilyTree.instance.add_child(*params)
when 'GET_RELATIONSHIP'
- puts FamilyTree.instance.get_relationship(*params)
+ result = FamilyTree.instance.get_relationship(*params)
+ result && puts(result)
end
end
diff --git a/lib/family_tree.rb b/lib/family_tree.rb
index 5ba8c72..9850280 100644
--- a/lib/family_tree.rb
+++ b/lib/family_tree.rb
@@ -38,6 +38,8 @@ class FamilyTree
parent = result[:person]
parent_of_family = result[:parent_of_family]
+ return 'PERSON_NOT_FOUND' if parent.is_a?(NilPerson)
+
if parent_of_family.nil? || parent_of_family.mother.is_a?(NilPerson) || parent_of_family.father.eql?(parent)
return 'CHILD_ADDITION_FAILED'
end
@@ -82,7 +84,7 @@ class FamilyTree
when 'brother-in-law'
handle_brother_in_law_relationship(person, child_of_family)
else
- 'UNSUPPORTED_RELATIONSHIP'
+ false
end
end
@@ -130,7 +132,7 @@ class FamilyTree
daughters = children.select { |child| child.gender == Gender::FEMALE }
daughters.empty? ? 'NONE' : daughters.map(&:name).join(' ')
else
- 'UNSUPPORTED_RELATIONSHIP'
+ false
end
end