Class: Subtitle
- Inherits:
-
Object
- Object
- Subtitle
- Defined in:
- lib/rsrt/subtitle.rb
Instance Attribute Summary collapse
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(details = {}) ⇒ Subtitle
constructor
A new instance of Subtitle.
- #shift_time_range_backward(shift) ⇒ Object
- #shift_time_range_forward(shift) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(details = {}) ⇒ Subtitle
Returns a new instance of Subtitle.
5 6 7 8 9 |
# File 'lib/rsrt/subtitle.rb', line 5 def initialize(details={}) @id = details[:id].to_i @text = details[:text] parse_time_range(details[:time_range]) end |
Instance Attribute Details
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
3 4 5 |
# File 'lib/rsrt/subtitle.rb', line 3 def end_time @end_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rsrt/subtitle.rb', line 3 def id @id end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/rsrt/subtitle.rb', line 3 def start_time @start_time end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/rsrt/subtitle.rb', line 3 def text @text end |
Instance Method Details
#shift_time_range_backward(shift) ⇒ Object
16 17 18 19 |
# File 'lib/rsrt/subtitle.rb', line 16 def shift_time_range_backward(shift) @start_time.from_ms(@start_time.to_ms - shift) @end_time.from_ms(@end_time.to_ms - shift) end |
#shift_time_range_forward(shift) ⇒ Object
11 12 13 14 |
# File 'lib/rsrt/subtitle.rb', line 11 def shift_time_range_forward(shift) @start_time.from_ms(@start_time.to_ms + shift) @end_time.from_ms(@end_time.to_ms + shift) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/rsrt/subtitle.rb', line 21 def to_s @id.to_s + "\n" + @start_time.to_s + " --> " + @end_time.to_s + "\n" + @text.to_s end |