Sha256: 25bbdb405767179d4ff09c057b349274d46efab3dc4e0ea2628ac3c021d9e1f7

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

# This class gives a set of operations
module VORuby
  module ADQL
    
    class Operations
    
      # This method returns an array of column names. For now, it reads
      # a file from somewhere path. In the future we'll have a service
      # that will return a xml file with similar information.
      #[_path_]
      # It's temporal param
      def self.get_columns(path)
        columns_array = [{'name'=>'All'}]
      
        document = REXML::Document.new(File.new(path))#This is temporal way
        raise "Document haven't elements" if document.root == nil
      
        document.root.elements.each('String') do |element|
          columns_array.push({'name'=>element.text})
        end
      
        return columns_array
      end
    
      # This method returns an array of column info. For now, it reads 
      # a file from somewhere path. In the future we'll have a service
      # that will return a xml file with similar information.
      #[_path_]
      # It's temporal param
      def self.get_meta_columns(path)
        columns_array = []
      
        document = REXML::Document.new(File.new(path))#This is temporal way
        raise "Document haven't elements" if document.root == nil
      
        document.root.elements.each('MetaColumn') do |meta_element|      
          node_name = REXML::XPath.first(meta_element, 'Name')
          node_unit = REXML::XPath.first(meta_element, 'Unit')
          node_des = REXML::XPath.first(meta_element, 'Description')
          node_ucd = REXML::XPath.first(meta_element, 'UCD')
        
          columns_array.push({'name'=> node_name.text,
                              'unit'=> node_unit.text,
                              'description'=> node_des.text,
                              'ucd'=>node_ucd.text})
        end
      
        return columns_array
      end
    
    end
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voruby-1.1.1 lib/voruby/adql/operations.rb
voruby-1.0.2 lib/voruby/adql/operations.rb
voruby-1.1 lib/voruby/adql/operations.rb
voruby-1.0.1 lib/voruby/adql/operations.rb