Class: NntpScrape::Commands::Head

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

Instance Attribute Summary collapse

Attributes inherited from Base

#lines, #response, #status_line, #timeout

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(number = nil) ⇒ Head

Returns a new instance of Head.



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

def initialize(number=nil)
  @number = number
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/nntp_scrape/commands/head.rb', line 5

def data
  @data
end

#message_idObject (readonly)

Returns the value of attribute message_id.



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

def message_id
  @message_id
end

Instance Method Details

#execute(client) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nntp_scrape/commands/head.rb', line 11

def execute(client)
  if @number.present?
    run_long client, "HEAD", @number
  else
    run_long client, "HEAD"          
  end
  
  
  @message_id = status_line.split.last
  @data = {}
  lines.each do |line|
    key, value = *line.split(": ", 2)
    @data[key] = value
  end        
end