-
-
Save Dysperen/a611b02e70e5160630e6598354309f2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @!visibility private | |
class Loader | |
require_relative 'excel/_kincom' | |
require_relative 'excel/_vo2max' | |
# Måske flytte error-messages til en seperat fil? | |
NEGATIVE = "There is a negative value. That doesn't make sense. Oxygen consumption cannot be negative" | |
IS_EMPTY = "The data array is empty. This cannot be good." | |
WRONG_FILE = "Excel worksheet is not as expected. Is it the raw output?" | |
def initialize(file) | |
@file = File.open(file, "r") | |
self | |
end | |
def excel(request) | |
raise ArgumentError, "No file has been loaded." if @file.nil? | |
case request | |
when :kincom | |
KincomLoader.new(@file) | |
when :vo2max | |
Vo2maxLoader.new(@file) | |
else | |
raise ArgumentError, "#{request.to_s} is not implemented in the loader module." | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestLoading < Minitest::Test | |
include TestHelperLoading | |
def setup | |
@kincom_file = './mockups/kincom/test_file.xlsx' | |
@vo2max_file = './mockups/vo2max/test_cosmed.xlsx' | |
end | |
def test_exceptions | |
assert_raises ArgumentError do Loader.new(@kincom_file).excel(:invalid) end; | |
end | |
def test_interface | |
assert_instance_of KincomLoader, Loader.new(@kincom_file).excel(:kincom) | |
assert_instance_of Vo2maxLoader, Loader.new(@vo2max_file).excel(:vo2max) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment