Class: Itest5ch::Comment
- Inherits:
-
Object
- Object
- Itest5ch::Comment
- Defined in:
- lib/itest5ch/comment.rb
Instance Attribute Summary collapse
- #date ⇒ Time
- #id ⇒ String
- #mail ⇒ String
- #message ⇒ String
- #name ⇒ String
- #number ⇒ Integer
- #thread ⇒ Itest5ch::Thread
Instance Method Summary collapse
- #anchor_numbers ⇒ Array<Integer> (also: #reply_numbers)
-
#id_checker_url ⇒ String?
Get Id checker url for http://hissi.org.
-
#initialize(number:, name:, mail:, date:, id:, message:, thread:) ⇒ Comment
constructor
A new instance of Comment.
- #pc_url ⇒ String
- #smartphone_url ⇒ String
Constructor Details
#initialize(number:, name:, mail:, date:, id:, message:, thread:) ⇒ Comment
Returns a new instance of Comment.
40 41 42 43 44 45 46 47 48 |
# File 'lib/itest5ch/comment.rb', line 40 def initialize(number:, name:, mail:, date:, id:, message:, thread:) # rubocop:disable Metrics/ParameterLists @number = number @name = name @mail = mail @date = date @id = id @message = @thread = thread end |
Instance Attribute Details
#date ⇒ Time
19 20 21 |
# File 'lib/itest5ch/comment.rb', line 19 def date @date end |
#id ⇒ String
23 24 25 |
# File 'lib/itest5ch/comment.rb', line 23 def id @id end |
#mail ⇒ String
15 16 17 |
# File 'lib/itest5ch/comment.rb', line 15 def mail @mail end |
#message ⇒ String
27 28 29 |
# File 'lib/itest5ch/comment.rb', line 27 def @message end |
#name ⇒ String
11 12 13 |
# File 'lib/itest5ch/comment.rb', line 11 def name @name end |
#number ⇒ Integer
7 8 9 |
# File 'lib/itest5ch/comment.rb', line 7 def number @number end |
#thread ⇒ Itest5ch::Thread
31 32 33 |
# File 'lib/itest5ch/comment.rb', line 31 def thread @thread end |
Instance Method Details
#anchor_numbers ⇒ Array<Integer> Also known as: reply_numbers
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/itest5ch/comment.rb', line 51 def anchor_numbers numbers = .scan(/[>>]+([0-90-9\-]+)/).map do |result| str = result.first.tr("0-9", "0-9") if (m = str.match(/([0-9]+)-([0-9]+)/)) (m[1].to_i..m[2].to_i).to_a else str.to_i end end numbers.flatten.compact end |
#id_checker_url ⇒ String?
Get Id checker url for http://hissi.org
83 84 85 86 87 88 89 |
# File 'lib/itest5ch/comment.rb', line 83 def id_checker_url return nil if !id || id.empty? ymd = date.strftime("%Y%m%d") encoded_id = Base64.strict_encode64(id).delete("=") "http://hissi.org/read.php/#{thread.board}/#{ymd}/#{encoded_id}.html" end |
#pc_url ⇒ String
68 69 70 |
# File 'lib/itest5ch/comment.rb', line 68 def pc_url "#{thread.pc_url}/#{number}" end |
#smartphone_url ⇒ String
73 74 75 |
# File 'lib/itest5ch/comment.rb', line 73 def smartphone_url "#{thread.smartphone_url}/#{number}" end |