Class: Castaway::Range

Inherits:
Object
  • Object
show all
Includes:
Times
Defined in:
lib/castaway/range.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Times

#_parse_numeric_time, #_parse_time, #_parse_timespec_time

Constructor Details

#initialize(production) ⇒ Range

Returns a new instance of Range.



31
32
33
34
35
# File 'lib/castaway/range.rb', line 31

def initialize(production)
  @production = production
  @start_frame = 0
  self.end_time = production.duration
end

Instance Attribute Details

#end_frameObject

Returns the value of attribute end_frame.



8
9
10
# File 'lib/castaway/range.rb', line 8

def end_frame
  @end_frame
end

#start_frameObject

Returns the value of attribute start_frame.



8
9
10
# File 'lib/castaway/range.rb', line 8

def start_frame
  @start_frame
end

Class Method Details

.at_frame(production, frame) ⇒ Object



10
11
12
13
14
15
# File 'lib/castaway/range.rb', line 10

def self.at_frame(production, frame)
  new(production).tap do |range|
    range.start_frame = frame
    range.end_frame = frame
  end
end

.at_scene(production, title) ⇒ Object



24
25
26
27
28
29
# File 'lib/castaway/range.rb', line 24

def self.at_scene(production, title)
  new(production).tap do |range|
    range.start_scene = title
    range.end_scene = title
  end
end

.at_time(production, time) ⇒ Object



17
18
19
20
21
22
# File 'lib/castaway/range.rb', line 17

def self.at_time(production, time)
  new(production).tap do |range|
    range.start_time = time
    range.end_time = time
  end
end

Instance Method Details

#end_scene=(title) ⇒ Object

Raises:

  • (ArgumentError)


63
64
65
66
67
# File 'lib/castaway/range.rb', line 63

def end_scene=(title)
  scene = @production.scene(title)
  raise ArgumentError, "no scene named #{title.inspect}" unless scene
  self.end_time = scene.finish
end

#end_timeObject



53
54
55
# File 'lib/castaway/range.rb', line 53

def end_time
  @end_frame / @production.fps.to_f
end

#end_time=(t) ⇒ Object



49
50
51
# File 'lib/castaway/range.rb', line 49

def end_time=(t)
  @end_frame = (_parse_time(t) * @production.fps).ceil
end

#start_scene=(title) ⇒ Object

Raises:

  • (ArgumentError)


57
58
59
60
61
# File 'lib/castaway/range.rb', line 57

def start_scene=(title)
  scene = @production.scene(title)
  raise ArgumentError, "no scene named #{title.inspect}" unless scene
  self.start_time = scene.start
end

#start_timeObject



45
46
47
# File 'lib/castaway/range.rb', line 45

def start_time
  @start_frame / @production.fps.to_f
end

#start_time=(t) ⇒ Object



41
42
43
# File 'lib/castaway/range.rb', line 41

def start_time=(t)
  @start_frame = (_parse_time(t) * @production.fps).floor
end

#truncated?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/castaway/range.rb', line 37

def truncated?
  start_frame > 0 || end_time < @production.duration
end