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.



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

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.



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

def dat
  @dat
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#numObject

Returns the value of attribute num.



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

def num
  @num
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#each(&blk) ⇒ Object



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

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

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



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

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