Class: Spread2RDF::Schema::Spreadsheet::DSL
- Inherits:
-
Object
- Object
- Spread2RDF::Schema::Spreadsheet::DSL
show all
- Defined in:
- lib/spread2rdf/schema/spreadsheet_dsl.rb
Instance Method Summary
collapse
Constructor Details
#initialize(schema, filename) ⇒ DSL
Returns a new instance of DSL.
6
7
8
9
10
11
|
# File 'lib/spread2rdf/schema/spreadsheet_dsl.rb', line 6
def initialize(schema, filename)
@schema = schema
@filename = filename
@templates = {}
@cell_mappings = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
35
36
37
|
# File 'lib/spread2rdf/schema/spreadsheet_dsl.rb', line 35
def method_missing(name, *args)
@templates[name] or super
end
|
Instance Method Details
#cell_mapping(name, &block) ⇒ Object
30
31
32
33
|
# File 'lib/spread2rdf/schema/spreadsheet_dsl.rb', line 30
def cell_mapping(name, &block)
raise "required block for cell_mapping #{name} missing" unless block_given?
@cell_mappings[name.to_sym] = block
end
|
#namespaces(namespaces) ⇒ Object
13
14
15
|
# File 'lib/spread2rdf/schema/spreadsheet_dsl.rb', line 13
def namespaces(namespaces)
namespaces.each { |name, namespace| Namespace[name] = namespace }
end
|
#template(name, &block) ⇒ Object
25
26
27
28
|
# File 'lib/spread2rdf/schema/spreadsheet_dsl.rb', line 25
def template(name, &block)
raise "required block for template #{name} missing" unless block_given?
@templates[name.to_sym] = block
end
|
#worksheet(name, options = {}, &block) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/spread2rdf/schema/spreadsheet_dsl.rb', line 17
def worksheet(name, options={}, &block)
source_name = options[:source_name] = name
name = ( options.delete(:name) || source_name ).to_sym
worksheet = @schema.worksheet[name] ||= Worksheet.new(@schema)
worksheet.update_attributes options.merge(name: name, source_name: source_name)
Sheet::DSL.new(self, worksheet, @filename, &block)
end
|