class Kirby

Public Class Methods

dance() click to toggle source
# File lib/kirbydance.rb, line 6
    def self.dance
        # Look for 'We da best' and replace with something cooler
        signature = lambda do |str|
            if str == 'We da best'
                return ">>> SWAG <<<"
            end
        end

        # This will be how many times the kirbies dance (10)
        puts "How many times will Kirby dance for you?"

        rotations = gets.chomp.to_i

        puts rotations

        rotations ||= 5 # In case the user hasn't submitted a number

        dance_moves = [
            "(>'-')>",
            " <('-'<)",
            "  (>'-')>",
            "   <('-'<)",
            "    (>'-')>",
            "     <('-'<)",
            "      (>'-')>"
        ]

        num_dance_moves = dance_moves.length

=begin

This is where we will find the amount of times the array loops

Rotations   = User Input
Length      = `dance_moves` Length

=end

        n = rotations * num_dance_moves * 2 # times 2 for reverse as well

        counter = 0

        n.times do |x|
            puts dance_moves[counter]
            zzz()

            counter += 1

            if x % num_dance_moves == 0 && x > 0
                dance_moves.reverse!
                counter = 0
            end
        end

        print signature.call('We da best') unless rotations == 5
    end
zzz() click to toggle source
# File lib/kirbydance.rb, line 2
def self.zzz
    sleep 0.10
end