class MultimediaParadise::LongFormatToMillisecondsConverter
Constants
- DEFAULT_INPUT
#¶ ↑
DEFAULT_INPUT
¶ ↑#¶ ↑
- UNITS_IN_MS
#¶ ↑
UNITS_IN_MS
¶ ↑#¶ ↑
Public Class Methods
[](i)
click to toggle source
#¶ ↑
MultimediaParadise::LongFormatToMillisecondsConverter
[]¶ ↑
Usage example:
MultimediaParadise::LongFormatToMillisecondsConverter['00:33:32.70']
#¶ ↑
# File lib/multimedia_paradise/misc/long_format_to_milliseconds_converter.rb, line 160 def self.[](i) new(i).result? # This returns the result in milliseconds. end
Public Instance Methods
add(i)
click to toggle source
determine_ms()
click to toggle source
#¶ ↑
determine_ms
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/long_format_to_milliseconds_converter.rb, line 81 def determine_ms if input?.to_s.include? ':' @ms = input?.split(':').each_with_index.map {|d, i| if i == 2 # Convert all , into . d = d.gsub(/,/,'.') if d.include? ',' end d.to_f * UNITS_IN_MS[i] }.reduce(:+).to_i.to_s # Store this in either integer or string. else @ms = input? end end
input?()
click to toggle source
ms?()
click to toggle source
#¶ ↑
ms?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/long_format_to_milliseconds_converter.rb, line 104 def ms? @ms end
Also aliased as: ms
output_result()
click to toggle source
output_result_in_seconds()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/long_format_to_milliseconds_converter.rb, line 52 def reset # ======================================================================= # # === @ms # ======================================================================= # @ms = 0.0 # ======================================================================= # # === @input # ======================================================================= # @input = nil end
result?()
click to toggle source
#¶ ↑
result¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/long_format_to_milliseconds_converter.rb, line 140 def result? @ms end
Also aliased as: result
run()
click to toggle source
set_input(i = DEFAULT_INPUT)
click to toggle source
#¶ ↑
set_input
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/long_format_to_milliseconds_converter.rb, line 66 def set_input(i = DEFAULT_INPUT) i = i.join(' ') if i.is_a? Array i = DEFAULT_INPUT if i.nil? i = i.to_s.dup.strip if i.include? 'std' i = (i.gsub(/std/,'').to_f * 60) * 1000 elsif i.include? 'minuten' i = (i.gsub(/minuten/,'').to_f * 60) * 1000 # We first need to get the result in milliseconds. end @input = i end