class Bitcourier::PeerList::Storage

Constants

PATH

Public Class Methods

new(list) click to toggle source
# File lib/bitcourier/peer_list.rb, line 51
def initialize list
  @list = list
end

Public Instance Methods

read() click to toggle source
# File lib/bitcourier/peer_list.rb, line 55
def read
  File.read(PATH).lines.map do |line|
    @list.store Peer.from_a(line.split('|'))
  end
rescue Errno::ENOENT
  return []
end
write() click to toggle source
# File lib/bitcourier/peer_list.rb, line 63
def write
  File.open(PATH, 'w') do |file|
    @list.peers.each do |peer|
      file.puts peer.to_a.join('|')
    end
  end
end