Top Level Namespace
- Includes:
- BattleroomMachinery, DataGenerationMachinery
Defined Under Namespace
Modules: Battleroom, BattleroomMachinery, DataGenerationMachinery Classes: ArrayAccessQuestion, ArrayAssignmentQuestion, DataStructureAccessQuestion, DataStructureAssignmentQuestion, DataStructureQuestion, FollowUpQuestion, HashAccessQuestion, HashAssignmentQuestion, MethodDefinitionQuestion, MethodInvocationQuestion, NestedDataStructureAccessQuestion, Question, VariableAssignmentQuestion, VariableReassignmentQuestion, VariableReferenceQuestion
Constant Summary collapse
- HASH_QUESTIONS =
-
All hashes must have *at least* 5 key values pairs.
-
All questions must have a possible variables names key, be hashes with *at least* 5 key values pairs
-
[ { data_structure: { home_team: 'Green Bay Packers', capacity: 72_928, established: 1957, publicly_owned: true, real_grass: true, price_of_beer: 5.5, namesake: 'Curly Lambeau', address: '1265 Lombardi', suite_count: 168, banners: true, }, possible_variable_names: ['lambeau_field', 'the_frozen_tundra'], }, { data_structure: { stars: ['Ryan Gosling', 'Rachel McAdams'], released: 2004, tearjerker: true, director: 'Nick Cassavetes', mtv_movie_award_count: 1, box_office_millions: 81.5, macho: false, }, possible_variable_names: ['the_notebook'], }, { data_structure: { stars: ['Nicholas Cage', 'Meryl Streep'], rt_rating: 98.0, released: 2002, director: 'Spike Jonze', based_on: 'The Orchid Thief', screenwriters: ['Charlie Kaufman', 'Donald Kaufman'], }, possible_variable_names: ['adaptation'], }, ]
- ARRAY_QUESTIONS =
[ { data_structure: [ 'Foundation', 'American Gods', 'The Gunslinger', 'Do Androids Dream of Electric Sheep?', 'A Scanner Darkly', 'We Can Build You', 'Dune', 'The Left Hand of Darkness', 'Stranger in a Strange Land', 'Sirens of Titan', 'Brave New World', 'Lord of the Rings', '1984', 'Farhenheit 451', 'Animal Farm', 'Watchmen', 'The Stand', '2001', 'Starship Troopers', 'The Time Machine', "Hitchhiker's Guide to the Galaxy", "Cat's Cradle", "Ender's Game", ], possible_variable_names: [ 'sci_fi_books', 'sci_fi_novels', 'sci_fi_titles', 'books', 'paperback_titles', 'fav_books', ].shuffle, }, { data_structure: $random_names_array, possible_variable_names: [ 'friends', 'enemies', 'co_workers', 'old_pals', 'new_friends', 'frenemies', 'lovers', 'admirers', 'haters', 'stalker_names', 'teammates' ].shuffle, }, { data_structure: (7..29).to_a.shuffle, possible_variable_names: [ 'fav_nums', 'lotto_nums', 'ages_of_children', 'fav_ages', 'jersey_numbers', 'lucky_numbers', 'unlucky_numbers', 'totals', ].shuffle, }, { data_structure: [ rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), rand(0.0..100.0).round(2), ].uniq, possible_variable_names: [ 'test_scores', 'win_percentages', 'yield_percentages', 'dividends', 'multiples', 'sums', 'products', 'monthly_bill_totals' ].shuffle, }, { data_structure: [ 'Patches', 'Falstaff', 'Whiskers', 'Trousers', 'Sammycat', 'Dunbar', 'Digsy', 'Bubs', 'Davy', 'Tomcat', 'Mr. Bigglesworth', 'Pinot', 'Claude', 'Jackson', 'Bootsniffer', 'Frank', 'Dogboy', 'Kittyhawk', 'Kitty the Cat', 'Tiny', ], possible_variable_names: [ 'cat_names', 'cats', 'kitties', 'felines', 'kittie_names' ].shuffle, }, { data_structure: [ 'Fixing a Hole', 'Michelle', 'Hey Jude', 'In My Life', 'A Day in the Life', 'If I Needed Someone', 'Nowhere Man', 'Dear Prudence', 'Julia', 'Good Night', 'Something', 'Sun King', 'Carry That Weight', 'Girl', 'What Goes On', 'The Word', 'Blackbird', 'Piggies', 'Rocky Racoon', 'Cry Baby Cry', 'Taxman', 'Eleanor Rigby', 'Yellow Submarine', 'Only a Northern Song', 'Mean Mr. Mustard', 'All My Loving', 'Norwegian Wood', 'Yesterday', 'Blue Jay Way', 'Hello, Goodbye', 'Penny Lane', 'All You Need is Love', 'The Fool on the Hill', "I'm So Tired", "I'm Only Sleeping", "I'll Follow the Sun", "I'm Looking Through You", ], possible_variable_names: [ 'beatles_songs', 'fav_beatles_tracks', 'fab_four_tunes', ].shuffle, }, { data_structure: [ 'When Harry Met Sally', 'How to Lose a Guy in 10 Days', 'Bridesmaids', 'Knocked Up', 'High Fidelity', 'Chasing Amy', 'What Women Want', 'Four Weddings and a Funeral', 'About a Boy', 'Notting Hill', 'His Girl Friday', "America's Sweethearts", "My Best Friend's Wedding", "There's Something About Mary", ], possible_variable_names: ['rom_coms'] }, { data_structure: [ 'The Moon and Antarctica', 'Perfect From Now On', 'Nighthawks at the Diner', 'Songs From a Room', 'Transformer', 'Songs of Love and Hate', 'Stereopathetic Soul Manure', "Frank's Wild Years", ], possible_variable_names: [ 'lyrically_brilliant_albums', 'seminal_indie_rock_records' ].shuffle }, { data_structure: [ 'Sixteen Stone', 'Nirvana MTV Unplugged 1994', 'Jagged Little Pill', 'Ten', 'Nevermind', 'Illmatic', 'The Downward Spiral', 'Odelay', 'Mellowgold', 'All Eyez On Me', 'Ready 2 Die', 'Blur', 'Parklife', 'Definitely Maybe', 'Keep It Like a Secret', '...Come Down', 'XO', 'Exile in Guyville', 'The Lonesome Crowded West', 'Crooked Rain, Crooked Rain', 'The Blue Album', 'Pinkerton', 'OK Computer', 'The Bends', 'Slanted & Enchanted', "What's the Story (Morning Glory)?", ], possible_variable_names: [ 'classics_from_the_nineties', 'nineties_classics', ].shuffle }, ]
- METHOD_QUESTONS =
[ { method_name: "calc_area", arg_count: 2, spec: "returns the product of its two arguments", eval_string: "calc_area(#{area_arg_one}, #{area_arg_two})", eval_answer: area_arg_one * area_arg_two }, { method_name: "calc_volume", arg_count: 3, spec: "returns the product of its three arguments", eval_string: "calc_volume(#{volume_arg_one}, #{volume_arg_two}, #{volume_arg_three})", eval_answer: volume_arg_one * volume_arg_two * volume_arg_three }, { method_name: "sum", arg_count: 2, spec: "returns the sum of its two arguments", eval_string: "sum(#{area_arg_one}, #{area_arg_two})", eval_answer: area_arg_one + area_arg_two }, { method_name: "double", arg_count: 1, spec: "returns its lone argument multiplied by 2", eval_string: "double(#{double_arg})", eval_answer: double_arg * 2 }, { method_name: "triple", arg_count: 1, spec: "returns its lone argument multiplied by 3", eval_string: "triple(#{area_arg_two})", eval_answer: area_arg_two * 3 }, { method_name: "quadruple", arg_count: 1, spec: "returns its lone argument multiplied by 4", eval_string: "quadruple(#{area_arg_one})", eval_answer: area_arg_one * 4 }, { method_name: "square", arg_count: 1, spec: "returns its lone argument to the second power", eval_string: "square(#{square_arg})", eval_answer: square_arg ** 2 }, { method_name: "cube", arg_count: 1, spec: "returns its lone argument to the third power", eval_string: "cube(#{cube_arg})", eval_answer: cube_arg ** 3 }, { method_name: "kelvin_to_celcius", arg_count: 1, spec: "returns its lone argument minus the Float value \e[0;33;49m273.15\e[0m", eval_string: "kelvin_to_celcius(#{cube_arg})", eval_answer: cube_arg - 273.15 }, { method_name: "celcius_to_kelvin", arg_count: 1, spec: "returns its lone argument added to the Float value \e[0;33;49m273.15\e[0m", eval_string: "celcius_to_kelvin(#{square_arg})", eval_answer: square_arg + 273.15 }, { method_name: "kilograms_to_pounds", arg_count: 1, spec: "returns its lone argument multiplied by the Float value " + "\e[0;33;49m2.2\e[0m", eval_string: "kilograms_to_pounds(#{kilograms_to_pounds_arg})", eval_answer: kilograms_to_pounds_arg * 2.2 }, { method_name: "meters_to_centimeters", arg_count: 1, spec: "returns its lone argument multiplied by the Fixnum value " + "\e[0;33;49m100\e[0m", eval_string: "meters_to_centimeters(#{kilograms_to_pounds_arg})", eval_answer: kilograms_to_pounds_arg * 100 }, { method_name: "grams_to_milligrams", arg_count: 1, spec: "returns its lone argument multiplied by the Fixnum value 1000", eval_string: "grams_to_milligrams(#{grams_to_milligrams_arg})", eval_answer: grams_to_milligrams_arg * 1000 }, # { # method_name: "convert_weeks_to_minutes", # arg_count: 1, # spec: "returns its lone argument multiplied the product of the Fixnum values 7, 24, and 60", # eval_string: "grams_to_milligrams(#{grams_to_milligrams_arg})", # eval_answer: grams_to_milligrams_arg * 1000 # }, { method_name: "convert_bytes_to_bits", arg_count: 1, spec: "returns its lone argument multiplied by the Fixnum value 8", eval_string: "convert_bytes_to_bits(#{convert_bytes_to_bits_arg})", eval_answer: convert_bytes_to_bits_arg * 8 }, ].shuffle
- VARIABLE_QUESTIONS =
[ # { # possible_variable_names: [ # "method_to_remove", # "callback_method", # "format_callback", # ], # possible_variable_values: [ # :username, # :age, # :first_name, # :last_name, # :email_address, # :album_count, # :year_of_birth # ] # }, { possible_variable_names: [ 'sign_in_count', 'unread_emails_count', 'fish_count', 'cat_count', 'user_count', 'admin_count', 'number_of_dogs', 'num_steaks', 'fav_number', 'lucky_number', 'head_count', 'consecutive_wins', 'consecutive_losses', 'unlucky_number', 'days_without_rain', 'years_without_championship', ].shuffle, possible_variable_values: (1..100).to_a.shuffle, }, { possible_variable_names: [ 'signed_in', 'authenticated', 'authorized', 'heartbroken', 'ecstatic', 'is_admin_user', 'likes_dogs', 'takes_baths', 'can_swim', 'can_ride_a_bike', 'tells_lies', 'is_homeowner', 'password_verified', 'has_drivers_license', 'orphaned', 'steals_candy', 'has_cold', 'athletic', 'docile', ].shuffle, possible_variable_values: [true, false].shuffle, }, { possible_variable_names: [ 'time_abroad', 'period_married', 'waiting_period', 'sentence_length', 'tenure', 'life_span', 'term_length', 'time_in_office', 'incumbency', 'stint_length', ].shuffle, possible_variable_values: [ 'too short', 'much too long', 'None, thank god.', 'brief', 'fleeting', 'short-lived', 'everlasting', 'overlong', 'unending', "#{rand(2..11)} months", "#{rand(2..11)} months", "#{rand(2..11)} months", "#{rand(2..20)} years", "#{rand(2..20)} years", "#{rand(2..20)} years", "#{rand(2..6)} days", "#{rand(2..6)} days", "#{rand(2..6)} days", ].uniq.shuffle, }, { possible_variable_names: [ 'pilot_name', 'point_guard', 'cook', 'chef', 'boss', 'rival', 'opponent', 'foe', 'partner', 'teammate', 'collaborator', 'subordinate', 'server', 'trooper', 'peacekeeper', 'best_friend', 'worst_enemy', 'oldest_friend', 'nemesis', 'comrade', 'team_captain', 'instructor_name', 'friend_for_life', 'dancer', 'lead_singer', 'drummer', 'guitarist', 'bassist', ].shuffle, possible_variable_values: $random_names_array.shuffle }, { possible_variable_names: [ 'percentage_gold', 'test_score', 'top_test_score', 'top_score', 'low_score', 'divisor', 'multiple', 'sum', 'dividend', 'total', 'share_percentage', 'percentage_gained', 'percentage_lost', ].shuffle, possible_variable_values: [ 'n/a', rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), rand(0.0..99.9).round([2, 3].sample), ].shuffle, }, ]
- NESTED_DATA_STRUCTURE_ACCESS_QUESTIONS =
some should start as arrays, others as hashes is awesome_print the best solution? I should keep whatever data structures I create brief I should keep the first key-value pair of a hash to simple datatypes. the second k-v pair should be the nested data structure key lengths should be close, for readability (keep in mind this is for absolute beginners)
[ { data_structure: [ { title: 'The Stone Roses', released: 1989 }, { title: 'Second Coming', released: 1994 }, ], possible_variable_names: ['stone_roses_albums'] }, { data_structure: [ { song_title: 'Material Girl', billboard_peak: 2 }, { song_title: 'Borderline', billboard_peak: 10 }, { song_title: 'Lucky Star', billboard_peak: 4 }, { song_title: 'Holiday', billboard_peak: 16 }, { song_title: 'Vogue', billboard_peak: 1 }, ], possible_variable_names: ['madonna_singles'] } ]
Constants included from Battleroom::Printable
Battleroom::Printable::CONGRATULATIONS
Instance Method Summary collapse
- #configure_pry ⇒ Object
-
#restore_pry_defaults ⇒ Object
for use in debugging.
Methods included from DataGenerationMachinery
#gen_business, #gen_business_email_address, #gen_business_name_under_16_characters, #gen_location, #gen_password, #gen_phone_number, #gen_random_names_array, #gen_user, #snake_case
Methods included from BattleroomMachinery
#clear_display, #determine_variable_follow_up_question, #naughty_input?, #rotate_array
Methods included from Battleroom::Exceptionable
#isolate_variable_name_from_name_error, #print_colorized_error_prompt, #print_colorized_type_error_prompt, #print_unexpected_end_of_input_explanation
Methods included from Battleroom::Printable
#battleprint, #codify, #colorized_arithmetic_operator_list, #dynamic_word_wrap, #format_class_for_output, #format_value_for_stdout_and_eval, #indent_all_lines_for_stdout, #print_congratulation, #print_menu_options, #random_congratulation
Instance Method Details
#configure_pry ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/battleroom/config/pry_config.rb', line 4 def configure_pry Pry.config.default_window_size = 0 Pry.config.quiet = true Pry.config.memory_size = 10 Pry.prompt = [proc { "> ".blue }, proc { "* ".blue }] # removes pry's exit command, which is run before any of the before_eval hooks, resulting in a pry session users can't escape Pry::Commands.delete("exit") # quiets pry error caused by self_termination (below) Pry.config.exception_handler = proc { |output, exception, _| } # short circuits pry REPL before eval, saving eval for Question Pry.config.hooks.add_hook :before_eval, :self_terminate do |last_input, pry_instance| begin # exports user input for availability $input = last_input unless last_input.include?("restore_pry_defaults") pry_instance.run_command("continue") end # quiets ArgumentError thrown by pry-byebug as a result of self_termination hook (above) rescue ArgumentError end end end |
#restore_pry_defaults ⇒ Object
for use in debugging
31 32 33 34 35 36 |
# File 'lib/battleroom/config/pry_config.rb', line 31 def restore_pry_defaults Pry.config.default_window_size = 15 Pry.config.quiet = false Pry.prompt = Pry::DEFAULT_PROMPT Pry.config.hooks.delete_hook :before_eval, :self_terminate end |