Class: Jekyll::JekyllRdf::Drops::RdfResourceClass

Inherits:
RdfResource show all
Defined in:
lib/jekyll/drops/rdf_resource_class.rb

Overview

Represents an RDF resource class to the Liquid template engine

Instance Attribute Summary collapse

Attributes inherited from RdfResource

#page, #site, #subResources

Attributes inherited from RdfTerm

#term

Instance Method Summary collapse

Methods inherited from RdfResource

#add_necessities, #blank?, #covered, #direct_classes, #filedir, #filename, #inspect, #iri, #page_url, #ready?, #render_path, #rendered?, #statements, #statements_as, #statements_as_object, #statements_as_predicate, #statements_as_subject

Methods inherited from RdfTerm

#==, #===, #add_necessities, build_term_drop, #eql?, #inspect, #ready?, #to_s

Constructor Details

#initialize(term, base = false) ⇒ RdfResourceClass

important for template mapping true if _config.yml assigned this class a template



41
42
43
44
45
46
47
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 41

def initialize(term, base = false)
  super(term)
  @base = base
  @lock = -1
  @lockNumber = 0
  @distance = 0
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



38
39
40
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 38

def base
  @base
end

#distanceObject (readonly)

distance to next class with template



35
36
37
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 35

def distance
  @distance
end

#lockObject

Returns the value of attribute lock.



34
35
36
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 34

def lock
  @lock
end

#pathObject

Returns the value of attribute path.



37
38
39
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 37

def path
  @path
end

#templateObject

Returns the value of attribute template.



36
37
38
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 36

def template
  @template
end

Instance Method Details

#add?(lock_number) ⇒ Boolean

Checks if this instance was already added to the breadth-first search in RdfClassExtraction.request_class_template.

Returns:

  • (Boolean)


85
86
87
88
89
90
91
92
93
94
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 85

def add? lock_number
  if @lock_number != lock_number
    # used to recognize different searchpasses of request_class_template
    @lock_number = lock_number
    @lock = -1
    true
  else
    false
  end
end

#find_direct_superclassesObject

Returns all classes from which term directly inherited



52
53
54
55
56
57
58
59
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 52

def find_direct_superclasses
  return @superclasses unless @superclasses.nil?
  query = "SELECT ?s WHERE{ #{@term.to_ntriples} <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?s }"
  selection = Jekyll::JekyllRdf::Helper::RdfHelper::sparql.
    query(query).map{ |solution| solution.s.to_s}
  @superclasses = selection
  return selection
end

#get_path_rootObject

Returns the beginning of the path leading to the found template



76
77
78
79
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 76

def get_path_root
  return self if @path.nil?
  @path.get_path_root
end

#propagate_template(distance) ⇒ Object

Propagate the current template to the parent of the breadth-first search in RdfClassExtraction.request_class_template.



65
66
67
68
69
70
71
# File 'lib/jekyll/drops/rdf_resource_class.rb', line 65

def propagate_template(distance)
  @distance = distance
  return if @path.nil?
  return unless @path.template.nil?
  @path.template = @template
  @path.propagate_template(distance + 1)
end