Class: Graphshaper::LoggingAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/graphshaper/adapters/logging_adapter.rb

Overview

A simple adapter for logging the created graph

Instance Method Summary collapse

Constructor Details

#initialize(vertex_logger_file, edge_logger_file) ⇒ LoggingAdapter


4
5
6
7
8
9
# File 'lib/graphshaper/adapters/logging_adapter.rb', line 4

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

Instance Method Details

#add_edge(edge_id, from_id, to_id) ⇒ Object


11
12
13
# File 'lib/graphshaper/adapters/logging_adapter.rb', line 11

def add_edge(edge_id, from_id, to_id)
  @edge_logger_file << "#{edge_id},#{from_id},#{to_id}\n"
end

#add_vertex(vertex_id) ⇒ Object


15
16
17
# File 'lib/graphshaper/adapters/logging_adapter.rb', line 15

def add_vertex(vertex_id)
  @vertex_logger_file << "#{vertex_id}\n"
end

#closeObject


19
20
21
22
# File 'lib/graphshaper/adapters/logging_adapter.rb', line 19

def close
  @vertex_logger_file.close
  @edge_logger_file.close
end