Class: YoutubeVideo::Timetag
- Inherits:
-
Object
- Object
- YoutubeVideo::Timetag
- Defined in:
- lib/YPBT/time_tag.rb
Overview
comment’s time tag infomation
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#tag_type ⇒ Object
Returns the value of attribute tag_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(start_time:, comment:, end_time: nil, like_count: nil, tag_type: nil) ⇒ Timetag
constructor
A new instance of Timetag.
Constructor Details
#initialize(start_time:, comment:, end_time: nil, like_count: nil, tag_type: nil) ⇒ Timetag
Returns a new instance of Timetag.
8 9 10 11 12 13 14 |
# File 'lib/YPBT/time_tag.rb', line 8 def initialize(start_time:, comment:, end_time: nil, like_count: nil, tag_type: nil) @start_time = string_to_time start_time @end_time = end_time @like_count = like_count ? like_count : comment.like_count @tag_type = tag_type end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
7 8 9 |
# File 'lib/YPBT/time_tag.rb', line 7 def comment @comment end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
7 8 9 |
# File 'lib/YPBT/time_tag.rb', line 7 def duration @duration end |
#end_time ⇒ Object
Returns the value of attribute end_time.
7 8 9 |
# File 'lib/YPBT/time_tag.rb', line 7 def end_time @end_time end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/YPBT/time_tag.rb', line 7 def start_time @start_time end |
#tag_type ⇒ Object
Returns the value of attribute tag_type.
7 8 9 |
# File 'lib/YPBT/time_tag.rb', line 7 def tag_type @tag_type end |
Class Method Details
.find(comment:) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/YPBT/time_tag.rb', line 37 def self.find(comment:) time_tag_pattern = /http.+?youtube.+?\?.+?t=.+?\>([0-9:]+)<\/a>/ start_times_string = comment.text_display.scan time_tag_pattern = start_times_string.map do |match_parts| .new(start_time: match_parts[0], comment: comment) end end |