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
| @places = { | |
| "a1" => " ", "a2" => " ", "a3" => " ", | |
| "b1" => " ", "b2" => " ", "b3" => " ", | |
| "c1" => " ", "c2" => " ", "c3" => " " | |
| } | |
| @columns = [ | |
| ['a1','a2','a3'], | |
| ['b1','b2','b3'], | |
| ['c1','c2','c3'], |
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
| class Lottery | |
| def self.rand_number | |
| randoms = [ ] | |
| loop do | |
| puts "Enter a random number" | |
| new_number = gets.chomp | |
| if new_number.to_s == rand(1..10).to_s | |
| puts "You are a winner" | |
| return | |
| else |
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
| class Calculator | |
| def amount_due(number) | |
| if invalid?(number) == true | |
| puts "Error message amount_due" | |
| exit | |
| else | |
| list = [number] | |
| while number != "done" |
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
| actual_number = rand(0..1000) | |
| puts "Can you guess the number I am thinking?" | |
| print "It is between 0 and 1000: " | |
| guess = 0 | |
| def invalid?(user_input) | |
| !!user_input.to_s.match(/\A\d+\z/) | |
| end | |
| while actual_number != (guess) |
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
| ➜ views git:(master) ✗ vim | |
| ➜ views git:(master) ✗ vim .gitignore | |
| ➜ views git:(master) ✗ git status | |
| # On branch master | |
| # Untracked files: | |
| # (use "git add <file>..." to include in what will be committed) | |
| # | |
| # .gitignore | |
| nothing added to commit but untracked files present (use "git add" to track) | |
| ➜ views git:(master) ✗ git status |
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
| test_scores = [75, 100, 85, 65, 84, 87, 95] | |
| sum_score = test_scores.inject { |sum, i| (sum + i) } | |
| sorted = test_scores.sort | |
| avg_score = sum_score / test_scores.count | |
| lowest_score = sorted.first | |
| highest_score = sorted.last |
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 'uri' | |
| class Browser | |
| def initialize(question) | |
| @question = question | |
| end | |
| def browse | |
| system("open", url) | |
| end |
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 guess_input | |
| puts "Word: #{@answer}(#{@letter_count.size}): " | |
| puts "Guesses remaining: #{@guess_left}" | |
| print "Guess a single letter (a-z) or the entire word: " | |
| @guess = gets.chomp | |
| end | |
| def correct_guess_output | |
| puts | |
| puts "Congradulations you\'ve guessed the word!" |
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
| #array to hash | |
| require "pry" | |
| salutations = [ | |
| 'Mr.', | |
| 'Mrs.', | |
| 'Mr.', | |
| 'Dr.', | |
| 'Ms.' | |
| ] |
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 "more_feature_cashier.rb" | |
| puts "Welcome to James\' coffee emporium!" | |
| product_list | |
| product_price | |
| choices_for_selection |
OlderNewer