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 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 |
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
| # 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 |
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 '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 |
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
| 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 (+) |