module BioVcf::RDF
RDF
support module. Original is part of bioruby-rdf by Pjotr Prins
Public Class Methods
escape_string_literal(literal)
click to toggle source
# File lib/bio-vcf/vcfrdf.rb, line 51 def RDF::escape_string_literal(literal) s = literal.to_s # Put a slash before every double quote if there is no such slash already s = s.gsub(/(?<!\\)"/,'\"') # Put a slash before a single slash if it is not \["utnr>\] if s =~ /[^\\]\\[^\\]/ s2 = [] s.each_char.with_index { |c,i| res = c if i>0 and c == '\\' and s[i-1] != '\\' and s[i+1] !~ /^[uUtnr\\"]/ res = '\\' + c end # p [i,c,s[i+1],res] s2 << res } s = s2.join('') end s end
quoted_stringify_literal(literal)
click to toggle source
# File lib/bio-vcf/vcfrdf.rb, line 75 def RDF::quoted_stringify_literal(literal) '"' + stringify_literal(literal) + '"' end
stringify_literal(literal)
click to toggle source
# File lib/bio-vcf/vcfrdf.rb, line 71 def RDF::stringify_literal(literal) RDF::escape_string_literal(literal.to_s) end
valid_uri?(uri)
click to toggle source
# File lib/bio-vcf/vcfrdf.rb, line 47 def RDF::valid_uri? uri uri =~ /^([!#$&-;=?_a-z~]|%[0-9a-f]{2})+$/i end