Class: Spread2RDF::Schema::Sheet
Defined Under Namespace
Classes: DSL
Instance Attribute Summary
Attributes inherited from Element
#block, #parent
Instance Method Summary
collapse
#resource_creation_mode, #resource_creation_namespace
Methods inherited from Element
#name, #source_name, #to_s, #worksheet
Methods included from Attributes
#init_attributes, #inspect, #update_attributes
Constructor Details
#initialize(parent, attr = {}, &block) ⇒ Sheet
Returns a new instance of Sheet.
12
13
14
15
16
|
# File 'lib/spread2rdf/schema/sheet.rb', line 12
def initialize(parent, attr = {}, &block)
super
@column = {}
@column_index = {}
end
|
Instance Method Details
#column_by_coord(coord) ⇒ Object
26
27
28
29
|
# File 'lib/spread2rdf/schema/sheet.rb', line 26
def column_by_coord(coord)
coord = Roo::Base.number_to_letter(coord) if coord.is_a? Integer
@column_index[coord]
end
|
#column_by_name(name = nil) ⇒ Object
Also known as:
column
31
32
33
34
35
|
# File 'lib/spread2rdf/schema/sheet.rb', line 31
def column_by_name(name = nil)
return @column if name.nil?
name = name.to_sym
@column[name] or ( parent.is_a?(Sheet) and parent.column(name) ) or nil
end
|
#column_range ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/spread2rdf/schema/sheet.rb', line 42
def column_range
first = columns.first.coord
first = first.begin if first.is_a? Range
last = columns.last.coord
last = last.end if last.is_a? Range
first .. last
end
|
#columns ⇒ Object
38
39
40
|
# File 'lib/spread2rdf/schema/sheet.rb', line 38
def columns
@column.values
end
|
#each_column(&block) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/spread2rdf/schema/sheet.rb', line 50
def each_column(&block)
columns.each do |column|
if column.is_a? ColumnBlock
column.each_column(&block)
else
yield column
end
end
end
|
#fix_row_count_per_resource ⇒ Object
68
69
70
|
# File 'lib/spread2rdf/schema/sheet.rb', line 68
def fix_row_count_per_resource
row_count_per_resource or ( !subject_column && 1 ) or nil
end
|
#resource_creation_attributes ⇒ Object
18
19
20
|
# File 'lib/spread2rdf/schema/sheet.rb', line 18
def resource_creation_attributes
subject
end
|
#start_coord ⇒ Object
22
23
24
|
# File 'lib/spread2rdf/schema/sheet.rb', line 22
def start_coord
Coord[start]
end
|
#subject_column ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/spread2rdf/schema/sheet.rb', line 60
def subject_column
column_name =
((subject = self.subject) &&
( ( subject[:uri].is_a?(Hash) && subject[:uri][:column] ) ||
subject[:column])) || :uri
@column[column_name]
end
|
#subject_resource_type ⇒ Object
72
73
74
75
76
|
# File 'lib/spread2rdf/schema/sheet.rb', line 72
def subject_resource_type
subject.try(:fetch, :type, nil) or
(subject.try(:fetch, :sub_class_of, nil) && RDF::RDFS.Class) or
nil
end
|