Class: Spread2RDF::Schema::Column
- Includes:
- StatementMapping
- Defined in:
- lib/spread2rdf/schema/column.rb
Instance Attribute Summary collapse
-
#coord ⇒ Object
readonly
this is set by Worksheet#index_columns!.
Attributes inherited from Element
Class Method Summary collapse
Instance Method Summary collapse
Methods included from StatementMapping
#restriction_mode, #statement_mapping_mode
Methods inherited from Element
#initialize, #name, #source_name, #worksheet
Methods included from Attributes
#init_attributes, #inspect, #update_attributes
Constructor Details
This class inherits a constructor from Spread2RDF::Schema::Element
Instance Attribute Details
#coord ⇒ Object (readonly)
this is set by Worksheet#index_columns!
46 47 48 |
# File 'lib/spread2rdf/schema/column.rb', line 46 def coord @coord end |
Class Method Details
.normalize_attributes(values) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/spread2rdf/schema/column.rb', line 12 def self.normalize_attributes(values) if object = values[:object] case when object.is_a?(Proc) then # nothing when !(from = object.delete(:from_worksheet) || object.delete(:from_sheet)).nil? object[:from] = { worksheet: from.to_sym } when !(from = object.delete(:from_data_source)).nil? object[:from] = { data_source: resolve_data_sources(from) } when !(from = object[:from]).nil? case from when Symbol then object[:from] = { worksheet: from } when String then object[:from] = { data_source: resolve_data_sources(from) } when Hash from[:data_source] = resolve_data_sources(from[:data_source]) if from.include?(:data_source) end end end values end |
.resolve_data_sources(data_sources) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spread2rdf/schema/column.rb', line 33 def self.resolve_data_sources(data_sources) return [data_sources] unless data_sources.is_a? Array data_sources.map do |data_source| case when (uri = data_source).is_a?(RDF::URI) || (uri = RDF::URI.new(data_source)).valid? raise NotImplementedError, "resolving of uris is not implemented yet" when data_source.is_a?(String) && !(file = File.in_path(data_source)).nil? RDF::Graph.load file else puts "WARNING: couldn't resolve data source #{data_source}" end end.compact end |
Instance Method Details
#cell_mapping ⇒ Object
65 66 67 |
# File 'lib/spread2rdf/schema/column.rb', line 65 def cell_mapping object if object.is_a?(Proc) end |
#object_mapping_mode ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/spread2rdf/schema/column.rb', line 54 def object_mapping_mode case when object.nil? then :to_string when object.is_a?(Proc) then :custom when !object[:uri].nil? then :new_resource when !object[:from].nil? then :resource_ref else raise "mapping specification error: don't know how to map #{self}" end end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/spread2rdf/schema/column.rb', line 50 def to_s "#{super} of #{sheet}" end |