Sha256: d2ebb48df2e4f3b5eed5d6c88ea2f04063ead10f659f32c22cf5183a814e6447

Contents?: true

Size: 1.39 KB

Versions: 8

Compression:

Stored size: 1.39 KB

Contents

module Spread2RDF
  module Schema
    class Worksheet < Sheet

      def init
        index_columns!
      end

      def index_columns!
        index = start_coord.column_as_number
        each_column do |column|
          index_letter = Roo::Base.number_to_letter(index)
          column.instance_variable_set :@coord, index_letter
          parent = column
          until parent.is_a? Worksheet
            parent = parent.parent
            column_index = parent.instance_variable_get :@column_index
            column_index[index_letter] = column
          end
          index += 1
        end
      end

      def dependent_sheets
        references = []
        each_column do |column|
          if column.object_mapping_mode == :resource_ref
            references << spreadsheet.worksheet[
                column.object[:from].try(:fetch, :worksheet)]
          end
        end
        references
      end

      def depends_on?(worksheet)
        return false unless worksheet.is_a? Worksheet
        return false if worksheet == self
        dependent_sheets = self.dependent_sheets
        return false if dependent_sheets.empty?
        return true if dependent_sheets.include? worksheet
        dependent_sheets.any? do |dependent_sheet|
          dependent_sheet != self and dependent_sheet.depends_on? worksheet
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spread2rdf-0.1.7 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.6 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.5 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.4 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.3 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.2 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.1 lib/spread2rdf/schema/worksheet.rb
spread2rdf-0.1.0 lib/spread2rdf/schema/worksheet.rb