Class: Subber::Subtitle
- Inherits:
-
Object
- Object
- Subber::Subtitle
- Defined in:
- lib/subber/subtitle.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
-
#end_time ⇒ Object
readonly
Returns the value of attribute end_time.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(attributes) ⇒ Subtitle
constructor
A new instance of Subtitle.
-
#shift(ms) ⇒ Subber::Subtitle
Return a copy with shifted subtitle.
-
#shift!(ms) ⇒ Object
mutates the current subtitle’s start and end time by ms.
Constructor Details
#initialize(attributes) ⇒ Subtitle
Returns a new instance of Subtitle.
7 8 9 10 11 12 |
# File 'lib/subber/subtitle.rb', line 7 def initialize(attributes) @counter = attributes[:counter] @start_time = attributes[:start_time] @end_time = attributes[:end_time] @content = attributes[:content] end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/subber/subtitle.rb', line 5 def content @content end |
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
2 3 4 |
# File 'lib/subber/subtitle.rb', line 2 def counter @counter end |
#end_time ⇒ Object (readonly)
Returns the value of attribute end_time.
4 5 6 |
# File 'lib/subber/subtitle.rb', line 4 def end_time @end_time end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
3 4 5 |
# File 'lib/subber/subtitle.rb', line 3 def start_time @start_time end |
Instance Method Details
#as_json ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/subber/subtitle.rb', line 14 def as_json { 'counter' => counter, 'start_time' => start_time, 'end_time' => end_time, 'content' => content } end |
#shift(ms) ⇒ Subber::Subtitle
Return a copy with shifted subtitle
26 27 28 29 30 31 32 33 |
# File 'lib/subber/subtitle.rb', line 26 def shift(ms) self.class.new( counter: counter, start_time: start_time + ms, end_time: end_time + ms, content: content ) end |
#shift!(ms) ⇒ Object
mutates the current subtitle’s start and end time by ms
38 39 40 41 |
# File 'lib/subber/subtitle.rb', line 38 def shift!(ms) @start_time += ms @end_time += ms end |