Sha256: 742d22cf32ced489aef2f28b0525f5400eada4d64d733053d567fc21e53b825b

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Playa
  class ProgressView < Vedeu::View
    include Playa::Helpers

    def render
      if object.track
        track_loaded

      else
        no_track_loaded

      end
    end

    private

    def track_loaded
      view 'progress' do
        line do
          stream do
            width progress_width
            text  progress_bar
          end

          stream do
            width timer_width
            text  timer
            align :right
          end
        end
      end
    end

    def no_track_loaded
      view 'progress' do
        line do
          stream do
            width view_width
            text  ' '
          end
        end
      end
    end

    def progress_width
      view_width - timer_width - 1
    end

    def progress_bar
      "\u{25FC}" * (object.progress * progress_width).ceil
    end

    def timer_width
      timer.size + 1
    end

    def timer
      remaining(object.track, object)
    end

    def view_width
      Vedeu.use('progress').viewport_width
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playa-0.0.15 lib/playa/views/progress_view.rb
playa-0.0.14 lib/playa/views/progress_view.rb
playa-0.0.13 lib/playa/views/progress_view.rb