Class: Jekyll::JekyllRdf::Drops::RdfTerm

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/jekyll/drops/rdf_term.rb

Overview

Represents an RDF term to the Liquid template engine

Direct Known Subclasses

RdfLiteral, RdfResource

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(term) ⇒ RdfTerm

Create a new Jekyll::JekyllRdf::Drops::RdfTerm

  • term - The term to be represented



45
46
47
# File 'lib/jekyll/drops/rdf_term.rb', line 45

def initialize(term)
  @term  ||= term
end

Instance Attribute Details

#termObject (readonly)

The represented RDF term



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

def term
  @term
end

Class Method Details

.build_term_drop(term, site, covered) ⇒ Object

Convert an RDF term into a new Jekyll::Drops::RdfTerm

  • term - The term to be represented

  • site - The Jekyll::Site to be enriched



90
91
92
93
94
95
96
97
98
99
# File 'lib/jekyll/drops/rdf_term.rb', line 90

def self.build_term_drop(term, site, covered)
  case term
  when RDF::URI, RDF::Node
    return Jekyll::JekyllRdf::Helper::RdfHelper.resources(term)
  when RDF::Literal
    return RdfLiteral.new(term)
  else
    return nil
  end
end

Instance Method Details

#==(other_obj) ⇒ Object



73
74
75
# File 'lib/jekyll/drops/rdf_term.rb', line 73

def ==(other_obj)
  return self.eql? other_obj
end

#===(other_obj) ⇒ Object



81
82
83
# File 'lib/jekyll/drops/rdf_term.rb', line 81

def ===(other_obj)
  return self.to_s.eql? other_obj.to_s
end

#add_necessities(site, page) ⇒ Object

Function stub with no functionality. Its purpose is to keep RdfResource compatible.



52
53
54
# File 'lib/jekyll/drops/rdf_term.rb', line 52

def add_necessities(site, page)
  return self
end

#eql?(other_obj) ⇒ Boolean

Returns:

  • (Boolean)


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

def eql? other_obj
  return (self.to_s.eql? other_obj.to_s)&&((other_obj.class <= self.class)||(self.class <= other_obj.class)||(other_obj.class <= self.term.class))
end

#inspectObject



101
102
103
104
# File 'lib/jekyll/drops/rdf_term.rb', line 101

def inspect
  obj_id = ('%x' % (self.object_id << 1)).to_s
  return "#<#{self.class.to_s.split("::")[-1]}:0x#{"0"*(14 - obj_id.length)}#{obj_id} @term=#{@term}>"
end

#ready?Boolean

Function stub with no functionality. Its purpose is to keep RdfResource compatible.

Returns:

  • (Boolean)


59
60
61
# File 'lib/jekyll/drops/rdf_term.rb', line 59

def ready?
  return true;
end

#to_sObject

Convert this RdfTerm into a string This should be:



69
70
71
# File 'lib/jekyll/drops/rdf_term.rb', line 69

def to_s
  term.to_s
end