Class: Jekyll::RdfTemplateMapper
- Inherits:
-
Object
- Object
- Jekyll::RdfTemplateMapper
- Includes:
- JekyllRdf::Helper::RdfClassExtraction
- Defined in:
- lib/jekyll/rdf_template_mapper.rb
Overview
Jekyll::RdfTemplateMapper maps resources to templates
Instance Method Summary collapse
-
#initialize(resources_to_templates, classes_to_templates, default_template) ⇒ RdfTemplateMapper
constructor
Create a new Jekyll::RdfTemplateMapper.
-
#map(resource) ⇒ Object
Maps a resource to a template name.
-
#print_warnings ⇒ Object
outputs all warnings prepared by RdfClassExtraction.consistence_templates.
Constructor Details
#initialize(resources_to_templates, classes_to_templates, default_template) ⇒ RdfTemplateMapper
Create a new Jekyll::RdfTemplateMapper
-
resources_to_templates
- A Hash mapping a type resource to a template name -
default_template
- Default template name
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jekyll/rdf_template_mapper.rb', line 40 def initialize(resources_to_templates, classes_to_templates, default_template) @resources_to_templates = resources_to_templates @default_template = default_template @classResources = {} @consistence = {} #ensures that the same template is chosen for each combination of templates @template_cache = {} @stop_object = StopObject.new create_resource_class(classes_to_templates) end |
Instance Method Details
#map(resource) ⇒ Object
Maps a resource to a template name.
Returns the template name of one of the resource
‘s types, if available. Returns the default template name otherwise.
55 56 57 58 59 60 |
# File 'lib/jekyll/rdf_template_mapper.rb', line 55 def map(resource) tmpl = @resources_to_templates ? @resources_to_templates[resource.term.to_s] : nil tmpl = request_class_template(resource) if tmpl.nil? return tmpl unless tmpl.nil? return @default_template end |
#print_warnings ⇒ Object
outputs all warnings prepared by RdfClassExtraction.consistence_templates
65 66 67 68 69 70 |
# File 'lib/jekyll/rdf_template_mapper.rb', line 65 def print_warnings @consistence.each{ |key, template_class_store| Jekyll.logger.warn("Warning: multiple possible templates for resources #{template_class_store[1].join(", ")}\nPossible Templates: #{key}") true } end |