Class: Hlsv::SdtmValidation::Define
- Inherits:
-
Object
- Object
- Hlsv::SdtmValidation::Define
- Defined in:
- lib/hlsv/sdtm_validation/define.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Array of String.
-
#keys ⇒ Object
readonly
Hash dataset: variables (Array of String).
-
#path ⇒ Object
readonly
String.
-
#status ⇒ Object
readonly
true/false/nil.
Instance Method Summary collapse
- #check_path(path) ⇒ Object
- #datasets ⇒ Object
- #define_key_for(ds) ⇒ Object
-
#initialize(infile) ⇒ Define
constructor
A new instance of Define.
-
#load_define ⇒ Object
load define from the config information return Nokogiri::Node.
Constructor Details
#initialize(infile) ⇒ Define
Returns a new instance of Define.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 10 def initialize(infile) @exception = [] @path = check_path(infile) node, @status = load_define @keys = get_define_keys(node) end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Array of String
8 9 10 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 8 def exception @exception end |
#keys ⇒ Object (readonly)
Hash dataset: variables (Array of String)
7 8 9 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 7 def keys @keys end |
#path ⇒ Object (readonly)
String
5 6 7 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 5 def path @path end |
#status ⇒ Object (readonly)
true/false/nil
6 7 8 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 6 def status @status end |
Instance Method Details
#check_path(path) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 21 def check_path(path) if path.nil? || path == '-' path elsif File.basename(path) == 'define.xml' path else if File.directory? path @exception << "The path isn't complete, it's a folder." @exception << "To find the file, add 'define.xml' to the folder in the config (already done here)." puts 'The define path is not complete.' "#{path}/define.xml" elsif File.exist? path path else @exception << "The file cannot be read: #{path.inspect}" nil end end end |
#datasets ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 79 def datasets if keys.nil? || keys == '-' [] else keys.keys end end |
#define_key_for(ds) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 87 def define_key_for(ds) if keys.nil? || keys == '-' [] else keys[ds] end end |
#load_define ⇒ Object
load define from the config information return Nokogiri::Node
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/hlsv/sdtm_validation/define.rb', line 47 def load_define # no define specify: define analyse part, not run with error if @path.nil? puts "no define specify" node = nil status = nil # no define expected: define analyse part, not run elsif @path == '-' puts "no define expected" node = '-' status = false # define present else begin node = File.open(@path, "rb") { |io| Nokogiri::XML(io, &:noblanks) } status = true puts "define.xml loaded" rescue => e puts "⚠ Error loading define.xml : #{e.}" node = nil status = nil @exception << 'Invalid path, update the config' end end [node, status] end |