Sha256: 112a47b6ce65dd54ea967e30e54256544d56723dc594d49c2833fca9c78c462a

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

module Graphshaper
  
  # A simple adapter for logging the created graph
  class LoggingAdapter
    def initialize(vertex_logger_file, edge_logger_file)
      @vertex_logger_file = vertex_logger_file
      @edge_logger_file = edge_logger_file
      @vertex_logger_file << "vertex_id\n"
      @edge_logger_file << "edge_id,from_id,to_id\n"
    end
    
    def add_edge(edge_id, from_id, to_id)
      @edge_logger_file << "#{edge_id},#{from_id},#{to_id}\n"
    end
    
    def add_vertex(vertex_id)
      @vertex_logger_file << "#{vertex_id}\n"
    end
    
    def close
      @vertex_logger_file.close
      @edge_logger_file.close
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphshaper-0.2.4 lib/graphshaper/adapters/logging_adapter.rb
graphshaper-0.2.3 lib/graphshaper/adapters/logging_adapter.rb