Class: Titlekit::Specification
- Inherits:
-
Object
- Object
- Titlekit::Specification
- Defined in:
- lib/titlekit/specification.rb
Instance Attribute Summary collapse
-
#subtitles ⇒ Object
Only for internal usage by the job.
Instance Method Summary collapse
-
#encoding(*args) ⇒ Object
Specifies the encoding you have or want.
-
#file(*args) ⇒ Object
Specifies the file (path) you have or want.
-
#fps(*args) ⇒ Object
Specifies the framerate you have or want.
-
#initialize ⇒ Specification
constructor
A new instance of Specification.
-
#reference(name, *_args, hours: nil, minutes: nil, seconds: nil, milliseconds: nil, srt_timecode: nil, ssa_timecode: nil, ass_timecode: nil) ⇒ Object
Places a named reference (in the form of a string or a symbol) on a timecode specified by either
hours
,minutes
,seconds
ormilliseconds
. -
#references ⇒ Object
Returns all named references you have specified.
-
#track(*args) ⇒ Object
Specifies the track the subtitles should be assigned to.
Constructor Details
#initialize ⇒ Specification
Returns a new instance of Specification.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/titlekit/specification.rb', line 7 def initialize @encoding = nil @file = nil @fps = nil @references = {} @subtitles = [] @track = nil self end |
Instance Attribute Details
#subtitles ⇒ Object
Only for internal usage by the job
5 6 7 |
# File 'lib/titlekit/specification.rb', line 5 def subtitles @subtitles end |
Instance Method Details
#encoding(*args) ⇒ Object
Specifies the encoding you have or want.
22 23 24 25 26 27 28 29 |
# File 'lib/titlekit/specification.rb', line 22 def encoding(*args) if args.empty? return @encoding else @encoding = args[0] return self end end |
#file(*args) ⇒ Object
Specifies the file (path) you have or want.
35 36 37 38 39 40 41 42 |
# File 'lib/titlekit/specification.rb', line 35 def file(*args) if args.empty? return @file else @file = args[0] return self end end |
#fps(*args) ⇒ Object
Specifies the framerate you have or want.
61 62 63 64 65 66 67 68 |
# File 'lib/titlekit/specification.rb', line 61 def fps(*args) if args.empty? return @fps else @fps = args[0] return self end end |
#reference(name, *_args, hours: nil, minutes: nil, seconds: nil, milliseconds: nil, srt_timecode: nil, ssa_timecode: nil, ass_timecode: nil) ⇒ Object
Places a named reference (in the form of a string or a symbol) on a timecode specified by either hours
, minutes
, seconds
or milliseconds
.
Its typical use-case is to reference a specific subtitle you can recognize in both the movie and your subtitle file, where usually for the subtitle file (represented by Have) you will reference the subtitle index and for the movie (represented by Want) you will reference the timecode that is displayed when the line occurs in the movie.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/titlekit/specification.rb', line 109 def reference(name, *_args, hours: nil, minutes: nil, seconds: nil, milliseconds: nil, srt_timecode: nil, ssa_timecode: nil, ass_timecode: nil) @references[name] = case when hours { timecode: hours * 3600 } when minutes { timecode: minutes * 60 } when seconds { timecode: seconds } when milliseconds { timecode: milliseconds / 1000 } when srt_timecode { timecode: Titlekit::SRT.parse_timecode(srt_timecode) } when ssa_timecode { timecode: Titlekit::SSA.parse_timecode(ssa_timecode) } when ass_timecode { timecode: Titlekit::ASS.parse_timecode(ass_timecode) } end self end |
#references ⇒ Object
Returns all named references you have specified
71 72 73 |
# File 'lib/titlekit/specification.rb', line 71 def references @references end |
#track(*args) ⇒ Object
Specifies the track the subtitles should be assigned to.
48 49 50 51 52 53 54 55 |
# File 'lib/titlekit/specification.rb', line 48 def track(*args) if args.empty? return @track else @track = args[0] return self end end |