Class: RubyProgress::Worm

Inherits:
Object
  • Object
show all
Includes:
WormRunner
Defined in:
lib/ruby-progress/worm.rb

Overview

Animated progress indicator with ripple effect using Unicode combining characters

Constant Summary collapse

RIPPLE_STYLES =

Ripple effect styles

{
  'circles' => {
    baseline: '·',  # middle dot
    midline: '',   # black circle
    peak: '' # large circle
  },
  'blocks' => {
    baseline: '',  # lower eighth block
    midline: '',   # lower half block
    peak: ''       # full block
  },
  'geometric' => {
    baseline: '',  # small black square
    midline: '',   # small white square
    peak: ''       # large black square
  },
  'cirlces_small' => {
    baseline: '',
    midline: '',
    peak: ''
  },
  'arrow' => {
    baseline: '',
    midline: '',
    peak: ''
  },
  'balloon' => {
    baseline: '.',
    midline: 'o',
    peak: '°'
  },
  'circle_open' => {
    baseline: '',
    midline: '',
    peak: ''
  }
}.freeze
SPEED_MAP =

Speed mappings

{
  'slow' => 0.5,
  'medium' => 0.2,
  'fast' => 0.1
}.freeze

Instance Method Summary collapse

Methods included from WormRunner

#animate, #animation_loop, #animation_loop_daemon_mode, #animation_loop_step, #run_daemon_mode, #run_indefinitely, #run_with_command, #stop

Constructor Details

#initialize(options = {}) ⇒ Worm

Returns a new instance of Worm.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ruby-progress/worm.rb', line 58

def initialize(options = {})
  @length = options[:length] || 3
  @message = options[:message]
  @speed = parse_speed(options[:speed] || 'medium')
  @style = parse_style(options[:style] || 'circles')
  @command = options[:command]
  @success_text = options[:success]
  @error_text = options[:error]
  @show_checkmark = options[:checkmark] || false
  @output_stdout = options[:stdout] || false
  @output_lines = options[:output_lines]
  @output_position = options[:output_position]
  @output_live = options[:stdout_live] || false
  @direction_mode = options[:direction] || :bidirectional
  @start_chars, @end_chars = RubyProgress::Utils.parse_ends(options[:ends])
  @running = false
end