summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/action_file_executor.rb11
-rw-r--r--lib/family_tree_manager.rb9
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/action_file_executor.rb b/lib/action_file_executor.rb
index 15d4f63..1cd3a94 100644
--- a/lib/action_file_executor.rb
+++ b/lib/action_file_executor.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require_relative 'family_tree_manager'
+
class ActionFileExecutor
def initialize(file_path)
@file_path = file_path
@@ -10,7 +12,14 @@ class ActionFileExecutor
File.open(@file_path, 'r') do |file|
file.each_line do |line|
action, *params = line.split(' ')
- puts "Executing action: #{action} with params: #{params.join(', ')}"
+ case action
+ when 'ADD_CHILD'
+ FamilyTreeManager.instance.add_child(*params)
+ when 'GET_RELATIONSHIP'
+ FamilyTreeManager.instance.query_hierarchy(*params)
+ else
+ puts "Ignoring unsupported action: [#{action}]"
+ end
end
end
end
diff --git a/lib/family_tree_manager.rb b/lib/family_tree_manager.rb
index 75e1b05..6b0bc12 100644
--- a/lib/family_tree_manager.rb
+++ b/lib/family_tree_manager.rb
@@ -9,6 +9,11 @@ class FamilyTreeManager
@family_members = {}
end
- def add_child(*params); end
- def query_hierarchy(*params); end
+ def add_child(*params)
+ puts "Adding Child with params: #{params.join(', ')}"
+ end
+
+ def query_hierarchy(*params)
+ puts "Querying Hierarcy with params: #{params.join(', ')}"
+ end
end