Sha256: b0408040cb4288d3099c1208bb7a1a488f9fd76a42cb51fa927151d625cd6ce9

Contents?: true

Size: 424 Bytes

Versions: 5

Compression:

Stored size: 424 Bytes

Contents

module Playa
  module Helpers
    def duration(track)
      human(track.duration.ceil)
    end

    def remaining(track, player)
      human((track.duration - player.counter).floor)
    end

    private

    def human(seconds)
      mm, ss    = seconds.divmod(60)
      hh, mm    = mm.divmod(60)
      mins      = mm.to_s.rjust(2, '0')
      secs      = ss.to_s.rjust(2, '0')

      [mins, secs].join(":")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
playa-0.1.0 lib/playa/helpers/helpers.rb
playa-0.0.15 lib/playa/helpers/helpers.rb
playa-0.0.14 lib/playa/helpers/helpers.rb
playa-0.0.13 lib/playa/helpers/helpers.rb
playa-0.0.12 lib/playa/helpers.rb