class Sc20XX::Views::PlayerView
draws and manages the top section of sc2000, the player
Attributes
player[RW]
Public Class Methods
new(*attrs)
click to toggle source
Calls superclass method
Sc20XX::UI::View::new
# File lib/sc20XX/views/player_view.rb, line 10 def initialize(*attrs) super @spectrum = true padding 3 end
Public Instance Methods
toggle_spectrum()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 17 def toggle_spectrum @spectrum = !@spectrum end
Protected Instance Methods
download_progress()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 40 def download_progress progress = @player.download_progress - @player.play_progress if progress > 0 '.' * (progress * body_width).ceil else '' end end
draw()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 23 def draw line progress + download_progress with_color(:orange) do line((duration + ' - ' + status).ljust(16) + @player.title) end line track_info line '>' * (@player.level.to_f * body_width).ceil end
duration()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 58 def duration TimeHelper.duration(@player.seconds_played.to_i * 1000) end
progress()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 36 def progress '#' * (@player.play_progress * body_width).ceil end
status()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 32 def status @player.playing? ? 'playing' : 'paused' end
track()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 50 def track @player.track end
track_info()
click to toggle source
# File lib/sc20XX/views/player_view.rb, line 54 def track_info "#{track.plays} Plays | #{track.likes} Likes | #{track.comments} Comments | #{track.url}" end