Class: Spread2RDF::Schema::Worksheet
- Defined in:
- lib/spread2rdf/schema/worksheet.rb
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
- #dependent_sheets ⇒ Object
- #depends_on?(worksheet) ⇒ Boolean
- #index_columns! ⇒ Object
- #init ⇒ Object
Methods inherited from Sheet
#column_by_coord, #column_by_name, #column_range, #columns, #each_column, #fix_row_count_per_resource, #initialize, #resource_creation_attributes, #start_coord, #subject_column, #subject_resource_type
Methods included from ResourceCreation
#resource_creation_mode, #resource_creation_namespace
Methods inherited from Element
#initialize, #name, #source_name, #to_s, #worksheet
Methods included from Attributes
#init_attributes, #inspect, #update_attributes
Constructor Details
This class inherits a constructor from Spread2RDF::Schema::Sheet
Instance Method Details
#dependent_sheets ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/spread2rdf/schema/worksheet.rb', line 24 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 |
#depends_on?(worksheet) ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spread2rdf/schema/worksheet.rb', line 35 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 |
#index_columns! ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spread2rdf/schema/worksheet.rb', line 9 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 |
#init ⇒ Object
5 6 7 |
# File 'lib/spread2rdf/schema/worksheet.rb', line 5 def init index_columns! end |