Class: Spread2RDF::Schema::Sheet::DSL
- Inherits:
-
Object
- Object
- Spread2RDF::Schema::Sheet::DSL
show all
- Defined in:
- lib/spread2rdf/schema/sheet_dsl.rb
Instance Method Summary
collapse
-
#cell(coord, options = {}, &block) ⇒ Object
-
#column(name, options = {}, &block) ⇒ Object
-
#column_block(name, options = {}, &block) ⇒ Object
-
#include(template, *args) ⇒ Object
-
#initialize(spreadsheet_dsl, worksheet, filename, &block) ⇒ DSL
constructor
-
#method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(spreadsheet_dsl, worksheet, filename, &block) ⇒ DSL
Returns a new instance of DSL.
5
6
7
8
9
10
|
# File 'lib/spread2rdf/schema/sheet_dsl.rb', line 5
def initialize(spreadsheet_dsl, worksheet, filename, &block)
@spreadsheet_dsl = spreadsheet_dsl
@worksheet = worksheet
@filename = filename
instance_exec(&block) if block_given?
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
47
48
49
|
# File 'lib/spread2rdf/schema/sheet_dsl.rb', line 47
def method_missing(name, *args)
__template__(name) or __cell_mapping__(name) or super
end
|
Instance Method Details
#cell(coord, options = {}, &block) ⇒ Object
26
27
28
29
30
|
# File 'lib/spread2rdf/schema/sheet_dsl.rb', line 26
def cell(coord, options = {}, &block)
content = ROO.cell(coord, @worksheet.source_name)
content = block.call(content) if block_given?
content
end
|
#column(name, options = {}, &block) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/spread2rdf/schema/sheet_dsl.rb', line 12
def column(name, options={}, &block)
name = name.to_sym
column = @worksheet.column[name] ||= Column.new(@worksheet, &block)
column.update_attributes options.merge(name: name)
column end
|
#column_block(name, options = {}, &block) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/spread2rdf/schema/sheet_dsl.rb', line 19
def column_block(name, options={}, &block)
name = name.to_sym
sub_sheet = @worksheet.column[name] ||= ColumnBlock.new(@worksheet)
sub_sheet.update_attributes options.merge(name: name)
DSL.new(@spreadsheet_dsl, sub_sheet, @filename, &block)
end
|
#include(template, *args) ⇒ Object
32
33
34
|
# File 'lib/spread2rdf/schema/sheet_dsl.rb', line 32
def include(template, *args)
instance_exec(*args, &__template__(template))
end
|