Class: NntpScrape::Commands::Base
- Inherits:
-
Object
- Object
- NntpScrape::Commands::Base
show all
- Defined in:
- lib/nntp_scrape/commands/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
7
8
9
|
# File 'lib/nntp_scrape/commands/base.rb', line 7
def initialize
@timeout = 5
end
|
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
4
5
6
|
# File 'lib/nntp_scrape/commands/base.rb', line 4
def lines
@lines
end
|
#response ⇒ Object
Returns the value of attribute response.
4
5
6
|
# File 'lib/nntp_scrape/commands/base.rb', line 4
def response
@response
end
|
#status_line ⇒ Object
Returns the value of attribute status_line.
4
5
6
|
# File 'lib/nntp_scrape/commands/base.rb', line 4
def status_line
@status_line
end
|
#timeout ⇒ Object
Returns the value of attribute timeout.
5
6
7
|
# File 'lib/nntp_scrape/commands/base.rb', line 5
def timeout
@timeout
end
|
Class Method Details
.supported?(client) ⇒ Boolean
11
12
13
|
# File 'lib/nntp_scrape/commands/base.rb', line 11
def self.supported?(client)
true
end
|
Instance Method Details
#continue? ⇒ Boolean
24
25
26
|
# File 'lib/nntp_scrape/commands/base.rb', line 24
def continue?
success? || status_code[0] == "3"
end
|
#execute(client) ⇒ Object
32
33
34
|
# File 'lib/nntp_scrape/commands/base.rb', line 32
def execute(client)
raise "implement in subclass"
end
|
#ran? ⇒ Boolean
15
16
17
|
# File 'lib/nntp_scrape/commands/base.rb', line 15
def ran?
status_line.present?
end
|
#run_long(client, cmd, *params) ⇒ Object
41
42
43
|
# File 'lib/nntp_scrape/commands/base.rb', line 41
def run_long(client, cmd, *params)
@status_line, @lines = *client.run_long(cmd, *params)
end
|
#run_short(client, cmd, *params) ⇒ Object
36
37
38
39
|
# File 'lib/nntp_scrape/commands/base.rb', line 36
def run_short(client, cmd, *params)
@status_line = client.run_short(cmd, *params).strip
end
|
#status_code ⇒ Object
28
29
30
|
# File 'lib/nntp_scrape/commands/base.rb', line 28
def status_code
@status_code ||= status_line.split.first
end
|
#success? ⇒ Boolean
19
20
21
22
|
# File 'lib/nntp_scrape/commands/base.rb', line 19
def success?
return false unless ran?
status_code[0] == "1" || status_code[0] == "2"
end
|