Class: Titlekit::Have

Inherits:
Specification show all
Defined in:
lib/titlekit/have.rb

Overview

Specifies existing input for a job.

Instance Attribute Summary

Attributes inherited from Specification

#subtitles

Instance Method Summary collapse

Methods inherited from Specification

#file, #fps, #references, #track

Constructor Details

#initializeHave

Returns a new instance of Have.



6
7
8
9
10
# File 'lib/titlekit/have.rb', line 6

def initialize
  super

  @encoding = :detect
end

Instance Method Details

#encoding(*args) ⇒ Object

Returns If you omit the argument it returns the already specified encoding.

Parameters:

  • A (String, Symbol)

    string specifying the encoding if it is known, (e.g. ‘UTF-8’, ‘ISO-8859-1’), :detect in case you don’t know, and :rchardet19 or :charlock_holmes if you have installed an additional detection library and want to specifically use one or the other.

Returns:

  • If you omit the argument it returns the already specified encoding



18
19
20
21
22
23
24
25
# File 'lib/titlekit/have.rb', line 18

def encoding(*args)
  if args.empty?
    return @encoding
  else
    @encoding = args[0]
    return self
  end
end

#reference(name, *_args, subtitle: nil, 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 either a subtitle index or 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 Titlekit::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.

Examples:

Referencing a subtitle index (ZERO-INDEXED! First subtitle is 0)

have.reference('Earl grey, hot', subtitle: 645)

Referencing a timecode by seconds

have.reference('In a galaxy ...', seconds: 14.2)

Referencing a timecode by an SRT-style timecode

have.reference('In a galaxy ...', srt_timecode: '00:00:14,200')

Referencing a timecode by an ASS-style timecode

have.reference('In a galaxy ...', ass_timecode: '0:00:14,20')

Referencing a timecode by an SSA-style timecode

have.reference('In a galaxy ...', ssa_timecode: '0:00:14,20')

Symbols can be used as references as well!

have.reference(:narrator_begins, minutes: 7.9)

Parameters:

  • name (String, Symbol)

    The name of the reference

  • subtitle (Integer) (defaults to: nil)

    Heads up: Numbering starts at 1!

  • hours (Float) (defaults to: nil)
  • minutes (Float) (defaults to: nil)
  • seconds (Float) (defaults to: nil)
  • milliseconds (Float) (defaults to: nil)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/titlekit/have.rb', line 62

def reference(name,
              *_args,
              subtitle: nil,
              hours: nil,
              minutes: nil,
              seconds: nil,
              milliseconds: nil,
              srt_timecode: nil,
              ssa_timecode: nil,
              ass_timecode: nil)

  if subtitle
    @references[name] = { subtitle: subtitle }
  else
    super(name,
          hours: hours,
          minutes: minutes,
          seconds: seconds,
          milliseconds: milliseconds,
          srt_timecode: srt_timecode,
          ssa_timecode: ssa_timecode,
          ass_timecode: ass_timecode)
  end

  self
end