Sha256: a8409000894846ab16fd81402a31751e7bf63da3e22863f17b3d58fef698968d

Contents?: true

Size: 842 Bytes

Versions: 6

Compression:

Stored size: 842 Bytes

Contents

module Spread2RDF
  module Mapping
    class Cell
      module Default
        def self.unit_mapping(value)
          @qudt ||= RDF::Graph.load File.join(ONTOLOGY_DIR, 'unit-v1.1.ttl')
          query = RDF::Query.new(
              unit: { RDF::URI.new('http://qudt.org/schema/qudt#symbol') =>
                        RDF::Literal.new(value, datatype: RDF::XSD.string) })
          solutions = query.execute(@qudt)
          raise "unit #{value} is not unique; possible candidates:
                    #{solutions.map(&:unit).ai}" if solutions.count > 1
          raise "couldn't find a QUDT unit for unit '#{value}''" if solutions.empty?
          solutions.first.unit
        end

        def self.uri_normalization(string)
          string
            .gsub(', ', '-')
            .gsub(' ', '-')
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spread2rdf-0.1.3 lib/spread2rdf/mapping/default_cell_mappings.rb
spread2rdf-0.1.2 lib/spread2rdf/mapping/default_cell_mappings.rb
spread2rdf-0.1.1 lib/spread2rdf/mapping/default_cell_mappings.rb
spread2rdf-0.1.0 lib/spread2rdf/mapping/default_cell_mappings.rb
spread2rdf-0.0.2 lib/spread2rdf/mapping/default_cell_mappings.rb
spread2rdf-0.0.1 lib/spread2rdf/mapping/default_cell_mappings.rb