Class: Dbd::Graph

Inherits:
Object
  • Object
show all
Includes:
Fact::Collection
Defined in:
lib/dbd/graph.rb

Overview

The Graph stores the Facts and ProvenanceFacts in an in-memory collection structure.

Instance Method Summary collapse

Methods included from Fact::Collection

#by_subject, #initialize, #newest_time_stamp, #oldest_time_stamp

Methods included from Helpers::OrderedSetCollection

add_and_return_index, #each, #initialize, #last, #size

Instance Method Details

#<<(recursive_fact_collection) ⇒ Object

Add a Fact or Resource or any set recursively.

This will add a time_stamp to the Facts.



16
17
18
19
20
21
# File 'lib/dbd/graph.rb', line 16

def <<(recursive_fact_collection)
  loop_recursively(recursive_fact_collection) do |fact|
    enforce_strictly_monotonic_time(fact)
    super(fact)
  end
end

#to_CSV ⇒ String

Export the graph to a CSV string

Returns:

  • (String) —

    comma separated string with double quoted cells



27
28
29
30
31
32
33
# File 'lib/dbd/graph.rb', line 27

def to_CSV
  CSV.generate(force_quotes: true) do |csv|
    @internal_collection.each do |fact|
      csv << fact.values
    end
  end.encode("utf-8")
end