class MultimediaParadise::MillisecondsToLongFormatConverter
Constants
- DEFAULT_INPUT
#¶ ↑
DEFAULT_INPUT
¶ ↑#¶ ↑
- FORMAT_STRING
#¶ ↑
FORMAT_STRING
¶ ↑This also “rounds” the result.
#¶ ↑
- N_SEKUNDEN_IN_EINER_STUNDE
#¶ ↑
N_SEKUNDEN_IN_EINER_STUNDE
¶ ↑#¶ ↑
Public Class Methods
convert(i)
click to toggle source
new( optional_input = ARGV, report_result = false, run_already = true )
click to toggle source
Public Instance Methods
do_conversion()
click to toggle source
#¶ ↑
do_conversion
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/milliseconds_to_long_format_converter.rb, line 90 def do_conversion input = (@n_milliseconds / 1000.0).to_s # Convert into seconds here. if input.include? '.' # We ensure that at least 3 characters are after the . splitted = input.split('.') splitted[1] << '0' if splitted[1].size < 3 splitted[1] << '0' if splitted[1].size < 3 input = splitted.join('.') end # Must have three numbers ms = input[-3,3].to_s.delete('.') input = input[0, input.length-3] total_sekunden = input.to_i stunden = (total_sekunden.to_i / N_SEKUNDEN_IN_EINER_STUNDE).to_s total_sekunden = total_sekunden - ( stunden.to_i * N_SEKUNDEN_IN_EINER_STUNDE ) minuten = total_sekunden.to_i / 60 total_sekunden = total_sekunden.to_i - (minuten.to_i * 60) minuten = '0'+minuten.to_s if minuten < 10 total_sekunden = '0'+total_sekunden.to_s if total_sekunden < 10 _ = stunden+':'+minuten.to_s+':'+total_sekunden.to_s+','+ms _[0,0] = '0' if stunden.to_i < 10 set_result _ report_result if @report_result end
report_result()
click to toggle source
#¶ ↑
report_result
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/milliseconds_to_long_format_converter.rb, line 118 def report_result e @result end
Also aliased as: report
reset()
click to toggle source
result?()
click to toggle source
#¶ ↑
result¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/milliseconds_to_long_format_converter.rb, line 133 def result? @result end
Also aliased as: result
run()
click to toggle source
set_n_milliseconds(i = nil)
click to toggle source
#¶ ↑
set_n_milliseconds
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/misc/milliseconds_to_long_format_converter.rb, line 63 def set_n_milliseconds(i = nil) i = DEFAULT_INPUT if i.nil? if i.is_a? Array if i.empty? i = DEFAULT_INPUT else i = i.first end end # ======================================================================= # # From this point on, we must have a String. # ======================================================================= # i = i.to_s.delete('_') if i.to_s.include? '_' i = i.to_i @n_milliseconds = i end
set_result(i)
click to toggle source