Class: NntpScrape::Commands::Xhdr

Inherits:
Base
  • Object
show all
Defined in:
lib/nntp_scrape/commands/xhdr.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#lines, #response, #status_line, #timeout

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#continue?, #ran?, #run_long, #run_short, #status_code, #success?

Constructor Details

#initialize(field, range) ⇒ Xhdr

Returns a new instance of Xhdr.



10
11
12
13
# File 'lib/nntp_scrape/commands/xhdr.rb', line 10

def initialize(field, range)
  @field = field
  @range = range
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



4
5
6
# File 'lib/nntp_scrape/commands/xhdr.rb', line 4

def results
  @results
end

Class Method Details

.supported?(client) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/nntp_scrape/commands/xhdr.rb', line 6

def self.supported?(client)
  client.caps.include? "XHDR"
end

Instance Method Details

#execute(client) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/nntp_scrape/commands/xhdr.rb', line 15

def execute(client)
  if @range.is_a? Range
    run_long client, "XHDR", @field, "#{@range.begin}-#{@range.end}"
  else
    run_long client, "XHDR", @field, @range         
  end
  
  @results = @lines.map{|l| l.split(" ")}
end