Skip to content

Instantly share code, notes, and snippets.

def fizzbuzz(size, &opt)
fb = [] # This is the FizzBuzz array.
i = 0
# Fill in the array with items we want.
size.times do |i|
if (i + 1) % 15 == 0
fb[i] = 'FizzBuzz' # Say "FizzBuzz" if divisible by 15.
elsif (i + 1) % 3 == 0
fb[i] = 'Fizz' # Say "Fizz" if divisible by 3.
elsif (i + 1) % 5 == 0
# Load YAML file
require 'yaml'
yml_file = YAML.load(File.read(ARGV[0]))
# Save header into an array
header = []
yml_file[0].each_key { |k| header << k }
# Save records into arrays
require 'yaml'
# Open and read a tsv file
tsv_lines = []
tsv_file = File.open(ARGV[0], 'r')
tsv_file.each_line do |line|
tsv_lines << line
end
tsv_file.close
@ichbinangela
ichbinangela / rubynotes
Last active October 4, 2015 12:16
Ruby notes
High-level
Interpreted
Object-oriented
Easy to use
designed by Yukihiro Matsumoto (often just called "Matz") in 1995.
3 data types: numbers, booleans, and strings.
case sensitive.
Addition (+)