Sha256: 6d7a1f75e13aa3dd0b8b42a0118294a282a124eab3a27e2b123980bb21aaf36c
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::Sugar::TopicMap module Resolve def deresolve(iri) if iri.is_a?(RTM::Locator) iri = iri.reference elsif iri.is_a?(String) iri = strip_identifier(iri) else raise("iri should be a String or Locator") end prefixes.each do |identifier, reference| if iri.index(reference) == 0 && iri.length > reference.length return iri.sub(reference, identifier + ":") elsif iri.index(base_iri) == 0 _iri = iri.sub(base_iri, "") return _iri if locator.resolve(_iri) == create_locator(iri) end end return iri end private def strip_identifier(identifier) case identifier when /^(si:|sl:|ii:|=|\^)$/ return "" when /^(\^|ii:)\s*(.*)/ #identifiers starts with ^ or ii: return $2 when /^(=|sl:)\s*(.+)/ #identifier starts with = or sl: return $2 when /^(si:)\s*(.+)/ #identifier starts with si: return $2 else #identifier does not start with a special character return identifier.lstrip #lstrip: leading whitespace chars removed end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rtm-0.3.1 | lib/rtm/sugar/topic_map/resolve.rb |