class Spread2RDF::Schema::Spreadsheet
Attributes
name[R]
worksheet[R]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/spread2rdf/schema/spreadsheet.rb, line 8 def initialize(name, &block) @name = name @worksheet = {} @schema_spec = block end
Public Instance Methods
map(input_file)
click to toggle source
# File lib/spread2rdf/schema/spreadsheet.rb, line 39 def map(input_file) mapping = Mapping::Spreadsheet.new(self, input_file) DSL.new(self, input_file).instance_exec(&@schema_spec) worksheets.each { |worksheet| worksheet.init } mapping.map mapping end
sorted_worksheets()
click to toggle source
# File lib/spread2rdf/schema/spreadsheet.rb, line 22 def sorted_worksheets unsorted_worksheets, sorted_worksheets = worksheets, [] unsorted_worksheets.reject! do |worksheet| worksheet.columns.empty? and sorted_worksheets << worksheet end while not unsorted_worksheets.empty? independent = unsorted_worksheets.find_index { |worksheet| unsorted_worksheets.none? do |other_worksheet| worksheet.depends_on? other_worksheet end } raise "schema contains cyclic dependencies" if independent.nil? sorted_worksheets << unsorted_worksheets.delete_at(independent) end sorted_worksheets end
spreadsheet()
click to toggle source
# File lib/spread2rdf/schema/spreadsheet.rb, line 14 def spreadsheet self end
worksheets()
click to toggle source
# File lib/spread2rdf/schema/spreadsheet.rb, line 18 def worksheets @worksheet.values end