module StructureChecker
Public Class Methods
check(structure)
click to toggle source
# File lib/clingon/helpers/structure_checker.rb, line 2 def self.check(structure) raise('Structure must be an array') unless structure.instance_of?(Array) StructureChecker.verify_contents(structure) structure end
verify_contents(structure)
click to toggle source
# File lib/clingon/helpers/structure_checker.rb, line 8 def self.verify_contents(structure) structure.each do |el| raise('Each element of structure must contain name key') unless el[:name] if el[:type] valid = [ 'int', 'float', 'num', 'bool' ] unless valid.include?(el[:type]) raise("Valid types are: #{valid.join(', ')}") end end end end