Class: Simple2ch::Thre
- Inherits:
-
Object
- Object
- Simple2ch::Thre
- Defined in:
- lib/simple2ch/thre.rb
Instance Attribute Summary collapse
-
#board ⇒ Board
readonly
属する板.
-
#num_of_response ⇒ Fixnum
readonly
返信の数.
-
#thread_key ⇒ String
readonly
スレッドキー(Unix time).
-
#title ⇒ String
readonly
スレッドの名前.
Class Method Summary collapse
-
.parse(board, thread_data) ⇒ Thre
板オブジェクトとsubject.txtの1行データを渡すとスレオブジェクトを返す.
Instance Method Summary collapse
-
#initialize(board, thread_key, title: '', num_of_response: '') ⇒ Thre
constructor
A new instance of Thre.
-
#kako_log? ⇒ Boolean
過去ログかどうかを返す.
-
#received_anchors ⇒ Hash
全てのレスに対し、あるレスへのアンカーが書き込まれているレス番号のハッシュを返す.
-
#reses(num_of_reses = nil) ⇒ Array<Res>
Datを解析して、レスを返す.
Constructor Details
#initialize(board, thread_key, title: '', num_of_response: '') ⇒ Thre
Returns a new instance of Thre.
16 17 18 19 20 21 22 23 24 |
# File 'lib/simple2ch/thre.rb', line 16 def initialize(board, thread_key, title: '', num_of_response: '') @board = board @thread_key = thread_key @title = title @num_of_response = num_of_response @reses = nil @f_kako_log = nil @received_anchors = nil end |
Instance Attribute Details
#board ⇒ Board (readonly)
Returns 属する板.
10 11 12 |
# File 'lib/simple2ch/thre.rb', line 10 def board @board end |
#num_of_response ⇒ Fixnum (readonly)
Returns 返信の数.
8 9 10 |
# File 'lib/simple2ch/thre.rb', line 8 def num_of_response @num_of_response end |
#thread_key ⇒ String (readonly)
Returns スレッドキー(Unix time).
6 7 8 |
# File 'lib/simple2ch/thre.rb', line 6 def thread_key @thread_key end |
#title ⇒ String (readonly)
Returns スレッドの名前.
4 5 6 |
# File 'lib/simple2ch/thre.rb', line 4 def title @title end |
Class Method Details
.parse(board, thread_data) ⇒ Thre
板オブジェクトとsubject.txtの1行データを渡すとスレオブジェクトを返す
30 31 32 33 34 35 36 37 |
# File 'lib/simple2ch/thre.rb', line 30 def self.parse(board, thread_data) thread_data =~ /(\d{10})\.dat<>(.+) \((\d+)\)/ hash = {} thread_key = $1 hash[:title] = $2 hash[:num_of_response] = $3.to_i self.new board, thread_key, hash end |
Instance Method Details
#kako_log? ⇒ Boolean
過去ログかどうかを返す
55 56 57 58 |
# File 'lib/simple2ch/thre.rb', line 55 def kako_log? fetch_dat if @f_kako_log.nil? @f_kako_log end |
#received_anchors ⇒ Hash
全てのレスに対し、あるレスへのアンカーが書き込まれているレス番号のハッシュを返す
62 63 64 |
# File 'lib/simple2ch/thre.rb', line 62 def received_anchors @received_anchors ||= calc_received_anchors end |
#reses(num_of_reses = nil) ⇒ Array<Res>
Datを解析して、レスを返す
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/simple2ch/thre.rb', line 42 def reses(num_of_reses=nil) fetch_dat unless @reses if num_of_reses && num_of_reses.size > 0 @reses.find_all{|r| num_of_reses.index(r.res_num) } else @reses end end |