Method: RDF::Graph#initialize
- Defined in:
- lib/rdf/model/graph.rb
#initialize(graph_name: nil, data: nil, **options) {|graph| ... } ⇒ Graph
Note:
Graph names are only useful when used as a projection
on a :data which supports named graphs. Otherwise, there is no
such thing as a named graph in RDF 1.1, a repository may have
graphs which are named, but the name is not a property of the graph.
Returns a new instance of Graph.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/rdf/model/graph.rb', line 106 def initialize(graph_name: nil, data: nil, **, &block) @graph_name = case graph_name when nil then nil when RDF::Resource then graph_name else RDF::URI.new(graph_name) end @options = .dup @data = data || RDF::Repository.new(with_graph_name: false) raise ArgumentError, "Can't apply graph_name unless initialized with `data` supporting graph_names" if @graph_name && !@data.supports?(:graph_name) if block_given? case block.arity when 1 then block.call(self) else instance_eval(&block) end end end |