Class: Substitute::Line
- Inherits:
-
Object
- Object
- Substitute::Line
- Defined in:
- lib/substitute/line.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #convert_timestamp(timestamp) ⇒ Object
- #finish ⇒ Object
- #identifier ⇒ Object
-
#initialize(text, options = {}) ⇒ Line
constructor
A new instance of Line.
- #line_with_identifier? ⇒ Boolean
- #parts ⇒ Object
- #remaining_text ⇒ Object
- #sep ⇒ Object
- #start ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text, options = {}) ⇒ Line
Returns a new instance of Line.
3 4 5 6 |
# File 'lib/substitute/line.rb', line 3 def initialize(text, = {}) self.text = text @srt = [:srt] end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/substitute/line.rb', line 8 def text @text end |
Instance Method Details
#convert_timestamp(timestamp) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/substitute/line.rb', line 34 def () times = .split(":") frames = times[3].to_i thous = (frames * 40).to_s.rjust(3, "0") "#{times[0..2].join(":")}#{sep}#{thous}" end |
#finish ⇒ Object
30 31 32 |
# File 'lib/substitute/line.rb', line 30 def finish (parts[2]) end |
#identifier ⇒ Object
22 23 24 |
# File 'lib/substitute/line.rb', line 22 def identifier parts[0] end |
#line_with_identifier? ⇒ Boolean
50 51 52 53 |
# File 'lib/substitute/line.rb', line 50 def line_with_identifier? return unless parts[0] parts[0].to_i.to_s == parts[0] end |
#parts ⇒ Object
18 19 20 |
# File 'lib/substitute/line.rb', line 18 def parts @_parts ||= text.split(" ") end |
#remaining_text ⇒ Object
46 47 48 |
# File 'lib/substitute/line.rb', line 46 def remaining_text parts[3..-1].join(" ") end |
#sep ⇒ Object
41 42 43 44 |
# File 'lib/substitute/line.rb', line 41 def sep return "," if srt? "." end |
#start ⇒ Object
26 27 28 |
# File 'lib/substitute/line.rb', line 26 def start (parts[1]) end |
#to_s ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/substitute/line.rb', line 10 def to_s if line_with_identifier? "\n#{identifier}\n#{start} --> #{finish}\n#{remaining_text}" else text end end |