class WhirledPeas::Command::Play

Start the animation

Attributes

player[R]

Public Class Methods

description() click to toggle source
# File lib/whirled_peas/command/play.rb, line 72
def self.description
  'Play an animation from an application or prerecorded file'
end

Public Instance Methods

start() click to toggle source
Calls superclass method WhirledPeas::Command::Base#start
# File lib/whirled_peas/command/play.rb, line 76
def start
  super
  player.play
end

Private Instance Methods

options_usage() click to toggle source
# File lib/whirled_peas/command/play.rb, line 105
def options_usage
  '<config/wpz file>'
end
validate!() click to toggle source
Calls superclass method WhirledPeas::Command::Base#validate!
# File lib/whirled_peas/command/play.rb, line 85
def validate!
  super
  @player = NullPlayer
  file = args.shift
  if file.nil?
    @error_text = "#{command_name} requires an config file or frames file file"
  elsif !File.exist?(file)
    @error_text = "File not found: #{file}"
  else
    full_path_file = file[0] == '/' ? file : File.join(Dir.pwd, file)
    if full_path_file.end_with?('.wpz')
      @player = FilePlayer.new(full_path_file)
    elsif full_path_file.end_with?('.rb')
      @player = ApplicationPlayer.new(full_path_file, config, build_logger)
    else
      @error_text = "Unsupported file type: .#{file.split('.').last}, epxecting .rb or .wpz"
    end
  end
end