Class: TAO::RDFizer
- Inherits:
-
Object
- Object
- TAO::RDFizer
- Defined in:
- lib/tao_rdfizer/tao_rdfizer.rb
Instance Method Summary collapse
-
#initialize(mode = nil) ⇒ RDFizer
constructor
if mode == :spans then produces span descriptions if mode == :annotations then produces annotation descriptions if mode == nil then produces both.
- #rdfize(annotations_col, options = nil) ⇒ Object
Constructor Details
#initialize(mode = nil) ⇒ RDFizer
if mode == :spans then produces span descriptions if mode == :annotations then produces annotation descriptions if mode == nil then produces both
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tao_rdfizer/tao_rdfizer.rb', line 10 def initialize(mode = nil) @mode = mode template = if !mode.nil? && mode == :spans ERB_SPANS_TTL else ERB_ANNOTATIONS_TTL end @tao_ttl_erb = ERB.new(template, trim_mode: '-') @prefix_ttl_erb = ERB.new(ERB_PREFIXES_TTL, trim_mode: '-') end |
Instance Method Details
#rdfize(annotations_col, options = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tao_rdfizer/tao_rdfizer.rb', line 21 def rdfize(annotations_col, = nil) ||= {} only_prefixes = [:only_prefixes] == true with_prefixes = [:with_prefixes] != true # check the format annotations_col.each do |annotations| raise "'target' is missing" unless annotations.has_key? :target end # namespaces namespaces = get_namespaces(annotations_col.first) prefixes_ttl = @prefix_ttl_erb.result_with_hash(namespaces:namespaces) if only_prefixes || with_prefixes return prefixes_ttl if only_prefixes annotations_ttl = get_annotations_ttl(annotations_col, namespaces) with_prefixes ? prefixes_ttl + annotations_ttl : annotations_ttl end |