summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSzymon Szukalski <szymon@skas.io>2024-10-24 13:04:16 +1100
committerSzymon Szukalski <szymon@skas.io>2024-10-24 13:04:16 +1100
commit3824dda1f184158c8946f02a4f2d533a17e95cd4 (patch)
tree099da455e7c8a85741257410b2feabd6ef5a0400 /lib
parent8d16abb3f57336af73b91e3e4b387f4936a8084d (diff)
Execute actions via the FamilyTreeManager
- Added logic for executing different FamilyTreeManager methods based on actions - More test coverage
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