Sha256: 335be4865850348893d29af9eb35abfa182b1b79ded3182120b1f42cb8e850ac

Contents?: true

Size: 637 Bytes

Versions: 1

Compression:

Stored size: 637 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

1 entries across 1 versions & 1 rubygems

Version Path
graphshaper-0.3.0 lib/graphshaper/adapters/logging_adapter.rb