class MultimediaParadise::StartLengthDuration
Constants
- DEBUG
#¶ ↑
DEBUG
¶ ↑#¶ ↑
Attributes
duration[R]
length[R]
start[R]
Public Class Methods
new( optional_input_duration = nil )
click to toggle source
Public Instance Methods
be_verbose()
click to toggle source
calculate_span()
click to toggle source
debug?()
click to toggle source
ensure_proper_values()
click to toggle source
#¶ ↑
ensure_proper_values
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/multimedia/start_length_duration.rb, line 139 def ensure_proper_values # We must keep them as integers and as positives. @length = @length.to_f.abs @start = @start.to_f.abs @duration = @duration.to_f.abs @span = @span.to_s # is a string. end
feedback()
click to toggle source
#¶ ↑
feedback¶ ↑
#¶ ↑
# File lib/multimedia_paradise/multimedia/start_length_duration.rb, line 95 def feedback cliner { e 'Length (Total length of this video file, in seconds): '+ simp(@length.to_s) e 'Start: '+simp(@start.to_s) e 'Duration: '+simp(@duration.to_s) e 'Span: '+simp(@span) } end
Also aliased as: debug
length=(i)
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
# File lib/multimedia_paradise/multimedia/start_length_duration.rb, line 55 def reset @length = 0 @start = 0 @duration = 0 @span = 0 @debug = DEBUG end
Also aliased as: initialize_variables
set_duration(i)
click to toggle source
#¶ ↑
set_duration
¶ ↑
Use this method when you want to set the @duration variable. This is the actual powerhorse of this script. Since Oct 2012 we will use the absolute value of any given input.
#¶ ↑
# File lib/multimedia_paradise/multimedia/start_length_duration.rb, line 160 def set_duration(i) i = i.to_s e "The Input to duration was: `"+sfancy(i)+'`' if debug? count = i.count('%') # How many of these do we have? if i.include? '%' # Ok, it could include one % or two % if count > 1 # has at least two. i = i.gsub(/%/,'') # get rid of the % first. # Now we assume that the two numbers given work in % start_pos, end_pos = i.split('-') # in percent. one_percent_is = length / 100.0 start_pos = one_percent_is * start_pos.to_i end_pos = (one_percent_is * end_pos.to_i) - start_pos set_start(start_pos) i = end_pos else i = i.gsub(/%/,'') # get rid of the % first. one_percent_is = length / 100.0 i = one_percent_is * i.to_i end end if i.to_s.include? '-' # Assume negative number means from right end. set_start(@length - i.to_i.abs) if count < 2 end @duration = i # Set @duration finally. ensure_proper_values calculate_span # This is a dependent variable. end
Also aliased as: set_duration=
set_end(i)
click to toggle source
set_length(i)
click to toggle source
set_start(i)
click to toggle source