Class: Jekyll::JekyllRdf::Drops::RdfLiteral

Inherits:
RdfTerm
  • Object
show all
Defined in:
lib/jekyll/drops/rdf_literal.rb

Overview

Represents an RDF literal to the Liquid template engine

Instance Attribute Summary

Attributes inherited from RdfTerm

#term

Instance Method Summary collapse

Methods inherited from RdfTerm

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

Constructor Details

This class inherits a constructor from Jekyll::JekyllRdf::Drops::RdfTerm

Instance Method Details

#literalObject

Return a user-facing string representing this RdfLiteral



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

def literal
  term.to_s
end

#to_liquidObject

Return literal value to allow liquid filters to compute rdf literals as well source: github.com/eccenca/jekyll-rdf/commit/704dd98c5e457a81e97fcd011562f1f39fc3f813



47
48
49
50
51
52
53
54
55
56
# File 'lib/jekyll/drops/rdf_literal.rb', line 47

def to_liquid
  # Convert scientific notation

  term_str = term.to_s
  if(term.has_datatype?)
    custom_type = Jekyll::JekyllRdf::Helper::Types::find(term.datatype)
    return custom_type.to_type term_str if (!custom_type.nil?) && (custom_type.match? term_str)
  end
  return term.to_s
end