Class: X2CH::Thread

Inherits:
Object
  • Object
show all
Defined in:
lib/x2ch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, dat, name, num) ⇒ Thread

Returns a new instance of Thread.



84
85
86
# File 'lib/x2ch.rb', line 84

def initialize(url, dat, name, num)
	@url, @dat, @name, @num = url, dat, name, num
end

Instance Attribute Details

#datObject

Returns the value of attribute dat.



82
83
84
# File 'lib/x2ch.rb', line 82

def dat
  @dat
end

#nameObject

Returns the value of attribute name.



82
83
84
# File 'lib/x2ch.rb', line 82

def name
  @name
end

#numObject

Returns the value of attribute num.



82
83
84
# File 'lib/x2ch.rb', line 82

def num
  @num
end

#urlObject

Returns the value of attribute url.



82
83
84
# File 'lib/x2ch.rb', line 82

def url
  @url
end

Instance Method Details

#each(&blk) ⇒ Object



98
99
100
101
102
# File 'lib/x2ch.rb', line 98

def each(&blk)
	posts.each{|p|	
		yield p
	}
end

#posts(if_modified_since = nil, range = nil) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/x2ch.rb', line 88

def posts(if_modified_since = nil, range = nil)
	if @url.match(/machi.to/)
		part = @url.match(/^(http:\/\/.+?)\/(.+?)\//).to_a
		res = Dat.download(part[1] + "/bbs/offlaw.cgi/" + part[2] + '/' + @dat.sub('.cgi', ''), if_modified_since, range)
	else
		res = Dat.download(@url + "dat/" + @dat, if_modified_since, range)
	end
	ArrayResponse.new(Dat.parse(res), res.status, res.last_modified, res.content_encoding, res.body_size)
end