Sha256: efb223cc1e4c63745fa08ffcb054dce8602d6c85f3588b04a2ddcade3a2dd22d
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
module Grom class Builder attr_reader :objects def initialize(reader) @reader = reader build_objects end def build_objects build_objects_by_subject link_objects @objects end def initialize_objects_hashes @objects, @objects_by_subject = [], {} end def build_objects_by_subject initialize_objects_hashes @reader.statements_by_subject.each do |subject, statements| object = Grom::Node.new(statements) @objects_by_subject[subject] = object @objects << object end self end def link_objects @reader.edges_by_subject.each do |subject, predicates| predicates.each do |predicate, object_uris| current_node = @objects_by_subject[subject] object_uris.each do |object_uri| predicate_name_symbol = "@#{predicate}".to_sym object_array = current_node.instance_variable_get(predicate_name_symbol) object_array = [] if object_array.is_a?(String) object_array << @objects_by_subject[object_uri] current_node.instance_variable_set(predicate_name_symbol, object_array) # TODO: Not sure about the above conditional end end end self end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
grom-0.3.5 | lib/grom/builder.rb |
grom-0.3.4 | lib/grom/builder.rb |
grom-0.3.2 | lib/grom/builder.rb |
grom-0.3.1 | lib/grom/builder.rb |
grom-0.3.0 | lib/grom/builder.rb |