Module: NmDatafile::DataLoading

Defined in:
lib/nm_datafile/data_loading.rb

Instance Method Summary collapse

Instance Method Details

#determine_file_type(attributes_hash) ⇒ Object



24
25
26
27
# File 'lib/nm_datafile/data_loading.rb', line 24

def determine_file_type(attributes_hash)
  attributes_hash = YAML::load attributes_hash
  attributes_hash["file_type"].to_sym
end

#determine_password(hash) ⇒ Object



29
30
31
32
# File 'lib/nm_datafile/data_loading.rb', line 29

def determine_password(hash)
  d = YAML::load hash[:encryption]
  clean_decrypt_string(d["password"])
end

#Load(file_path) ⇒ Object

(m) Load: loads a file into memory as an NmDatafile TODO: Make lowercase



6
7
8
9
# File 'lib/nm_datafile/data_loading.rb', line 6

def Load(file_path)
  zip_data = File.read(file_path)
  LoadBinaryData(zip_data)
end

#LoadBinaryData(binary_data) ⇒ Object

TODO: Make lowercase



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nm_datafile/data_loading.rb', line 12

def LoadBinaryData(binary_data)
  hash = extract_entities_from_binary_data(binary_data)
  
  file_type = determine_file_type(hash[:attributes])
  nmd = NmDatafile.new( file_type )
  
  nmd.load_attributes(hash[:attributes]) unless hash[:attributes].nil?
  nmd.load_encryption(hash[:encryption])
  
  nmd.load_data([*hash[:data_collections], *hash[:data_objects]])
end