lib/sxp/extensions.rb in sxp-0.1.0 vs lib/sxp/extensions.rb in sxp-0.1.2
- old
+ new
@@ -1,7 +1,5 @@
-require 'rdf'
-
##
# Extensions for Ruby's `Symbol` class.
class Symbol
##
# Returns `true` if this is a keyword symbol.
@@ -10,13 +8,19 @@
def keyword?
to_s[-1] == ?:
end
end
-##
-# Extensions for RDF::URI
-class RDF::URI
- # Original lexical value of this URI to allow for round-trip serialization.
- def lexical=(value); @lexical = value; end
- def lexical; @lexical; end
-end
+# Update RDF::URI if RDF is loaded
+begin
+ require 'rdf'
+ ##
+ # Extensions for RDF::URI
+ class RDF::URI
+ # Original lexical value of this URI to allow for round-trip serialization.
+ def lexical=(value); @lexical = value; end
+ def lexical; @lexical; end
+ end
+rescue LoadError
+ # Ignore
+end