-
Category: APTITUDES
- Performance
- Fighting
- Occultism
-
Category: POWERS
- Mental Paralysis
- Insubstantiality
- Communication
Last active
January 5, 2022 13:40
-
-
Save pronoiac/26df03298422841e9d143676f866aa8e to your computer and use it in GitHub Desktop.
shuffling yaml in ruby
This file contains 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
APTITUDES: | |
- Fighting | |
- Presence | |
- Aircraft | |
- Occultism | |
- Technology | |
- Business | |
- Performance | |
- Vehicles | |
POWERS: | |
- Absorption | |
- Insubstantiality | |
- Summoning | |
- Life Support | |
- Super Leap | |
- Burrowing | |
- Mental Blast | |
- Super Running | |
- Communication | |
- Mental Paralysis |
This file contains 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
#!/usr/bin/env ruby | |
require 'yaml' | |
require 'pp' # Pretty printer | |
# require 'byebug' # for debugging | |
# Open yaml File | |
# superstuff = YAML.load_file('/home/username/data/sample.yaml') | |
superstuff = YAML.load_file('categories.yml') # if you're running it from the same directory | |
# byebug | |
# puts "pause" | |
# Iterate through what's there, and hopefully randomly sample some data. | |
superstuff.each do |category| | |
# byebug | |
category_name = category.first | |
category_options = category.last | |
draw_3 = category_options.sample(3) | |
puts "- Category: #{category_name}" | |
draw_3.each do |item| | |
puts " - #{item}" | |
end | |
puts # blank line in between categories | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment