Class: MultimediaParadise::StartLengthDuration
- Inherits:
-
Object
- Object
- MultimediaParadise::StartLengthDuration
show all
- Includes:
- Colours
- Defined in:
- lib/multimedia_paradise/multimedia/start_length_duration.rb
Overview
Constant Summary
collapse
- DEBUG =
false
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(optional_input_duration = nil) ⇒ StartLengthDuration
44
45
46
47
48
49
50
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 44
def initialize(
optional_input_duration = nil
)
set_duration(optional_input_duration) if optional_input_duration
reset ensure_proper_values
end
|
Instance Attribute Details
#duration ⇒ Object
Keeps the right values for the duration. In seconds.
32
33
34
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 32
def duration
@duration
end
|
#length ⇒ Object
30
31
32
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 30
def length
@length
end
|
#start ⇒ Object
Specify where to start. In seconds.
31
32
33
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 31
def start
@start
end
|
Instance Method Details
#be_verbose ⇒ Object
108
109
110
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 108
def be_verbose
@debug = true
end
|
#calculate_span ⇒ Object
88
89
90
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 88
def calculate_span @span = "#{@start}-"+(@start + @duration).to_s
end
|
#debug? ⇒ Boolean
149
150
151
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 149
def debug?
@debug
end
|
#ensure_proper_values ⇒ Object
139
140
141
142
143
144
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 139
def ensure_proper_values @length = @length.to_f.abs
@start = @start.to_f.abs
@duration = @duration.to_f.abs
@span = @span.to_s end
|
#feedback ⇒ Object
Also known as:
debug
95
96
97
98
99
100
101
102
103
|
# 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
|
#reset ⇒ Object
Also known as:
initialize_variables
55
56
57
58
59
60
61
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 55
def reset
@length = 0
@start = 0
@duration = 0
@span = 0
@debug = DEBUG
end
|
#set_duration(i) ⇒ Object
Also known as:
set_duration=
#
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.
#
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# 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('%') if i.include? '%' if count > 1 i = i.gsub(/%/,'') start_pos, end_pos = i.split('-') 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(/%/,'') one_percent_is = length / 100.0
i = one_percent_is * i.to_i
end
end
if i.to_s.include? '-' set_start(@length - i.to_i.abs) if count < 2
end
@duration = i ensure_proper_values
calculate_span end
|
#set_end(i) ⇒ Object
66
67
68
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 66
def set_end(i) set_duration(i.to_i - @start)
end
|
#set_length(i) ⇒ Object
73
74
75
76
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 73
def set_length(i)
@length = i.to_f
ensure_proper_values
end
|
#set_start(i) ⇒ Object
131
132
133
134
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 131
def set_start(i) @start = i.to_f
ensure_proper_values
end
|
#span? ⇒ Boolean
Also known as:
span
#
span?
Give the total duration. Formula: start + duration. In String format.
#
117
118
119
|
# File 'lib/multimedia_paradise/multimedia/start_length_duration.rb', line 117
def span?
@span
end
|