class WhirledPeas::Command::Record

Attributes

out_file[R]

Public Class Methods

description() click to toggle source
# File lib/whirled_peas/command/record.rb, line 6
def self.description
  'Record animation to a file'
end

Public Instance Methods

start() click to toggle source
# File lib/whirled_peas/command/record.rb, line 10
def start
  super
  require 'highline'
  require 'whirled_peas/animator/renderer_consumer'
  require 'whirled_peas/animator/producer'
  require 'whirled_peas/device/output_file'

  width, height = HighLine.new.terminal.terminal_size
  consumer = Animator::RendererConsumer.new(
    WhirledPeas.config.template_factory,
    Device::OutputFile.new(out_file),
    width,
    height
  )
  Animator::Producer.produce(consumer) do |producer|
    config.application.start(producer)
  end
end

Private Instance Methods

options_usage() click to toggle source
# File lib/whirled_peas/command/record.rb, line 50
def options_usage
  [*super, '<output file>'].join(' ')
end
validate!() click to toggle source
# File lib/whirled_peas/command/record.rb, line 33
def validate!
  super
  return unless @error_text.nil?

  out_file = args.shift
  if out_file.nil?
    @error_text = "#{command_name} requires an output file"
  elsif !out_file.end_with?('.wpz')
    if out_file.split('/').last =~ /\./
      extra = ", found: .#{out_file.split('.').last}"
    end
    @error_text = "Expecting output file with .wpz extension#{extra}"
  else
    @out_file = out_file[0] == '/' ? out_file : File.join(Dir.pwd, out_file)
  end
end