This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fileutils' | |
path = '/Users/rubyginner/Downloads' | |
docs = ['.pdf', '.epub', '.txt', '.rtf'] | |
pics = ['.png', '.gif', '.jpg', '.jpeg','.bmp', '.JPEG', '.JPG'] | |
music = ['.mp3', '.wav'] | |
videos = ['.mp4', '.wmv', '.flv', '.mov', '.mpeg'] | |
apps = ['.dmg', '.pkg'] | |
archive = ['.zip', '.tar'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def palindrome?(word) | |
return (word == word.reverse) ? true : false | |
end | |
puts "Enter a word to see if it's a palindrome..." | |
word = gets.chomp | |
puts "The word #{word} is #{palindrome?(word.to_s) ? 'a' : 'not a'} palindrome." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path = 'C:/folio-gallery/albums' | |
valid_files = ['.png', '.jpg', '.jpeg'] | |
Dir.foreach(path) { |folder| | |
next if ['.', '..'].include? folder | |
puts "#{folder}" | |
Dir.foreach("#{path}/#{folder}") { |subfolder| | |
puts "- #{subfolder}" if valid_files.include? File.extname(subfolder) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#calculate remaining VL and SL | |
def remaining_leaves(vl_taken, sl_taken) | |
month_now = Time.now.month | |
vl_remaining = ((month_now.to_f*1.25) - vl_taken.to_i) | |
sl_remaining = ((month_now.to_f*1.25) - sl_taken.to_i) | |
return "Remaining VL: #{vl_remaining.to_f} Remaining SL: #{sl_remaining.to_f}" | |
end | |
puts "How many VLs have you taken? " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# version 1 | |
(1..10).each { |y| | |
(1..10).each { |x| | |
print "#{x * y} " | |
} | |
puts '' | |
} | |
# version 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# version 1 | |
for counter in 1..100 | |
if (counter % 3 == 0) && (counter % 5 == 0) | |
puts 'FooBar' | |
elsif (counter % 3 == 0) | |
puts 'Foo' | |
elsif (counter % 5 == 0) | |
puts 'Bar' | |
else |