Class: NntpScrape::Repl

Inherits:
Object
  • Object
show all
Includes:
Commands
Defined in:
lib/nntp_scrape/repl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Repl

Returns a new instance of Repl.



9
10
11
# File 'lib/nntp_scrape/repl.rb', line 9

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/nntp_scrape/repl.rb', line 7

def client
  @client
end

Instance Method Details

#long(cmd, *params) ⇒ Object



34
35
36
37
38
39
# File 'lib/nntp_scrape/repl.rb', line 34

def long(cmd, *params)
  @client.run_long(cmd, *params)
rescue Errno::EPIPE, Errno::ECONNRESET, OpenSSL::SSL::SSLError
  @client.open
  retry
end

#run(klass, *params) ⇒ Object



21
22
23
24
25
# File 'lib/nntp_scrape/repl.rb', line 21

def run(klass, *params)
  cmd = klass.new(*params)
  @client.run(cmd)
  cmd
end

#short(cmd, *params) ⇒ Object



27
28
29
30
31
32
# File 'lib/nntp_scrape/repl.rb', line 27

def short(cmd, *params)
  @client.run_short(cmd, *params)
rescue Errno::EPIPE, Errno::ECONNRESET, OpenSSL::SSL::SSLError
  @client.open
  retry
end

#startObject



13
14
15
16
17
18
19
# File 'lib/nntp_scrape/repl.rb', line 13

def start
  my_prompt = [ 
    proc { |obj, *| ">> " },
    proc { |obj, *| "*> "} 
  ]
  binding.pry :quiet => true, :cli => true, :prompt => my_prompt
end