Skip to content

Instantly share code, notes, and snippets.

View troyleach's full-sized avatar
💭
😃

Troy troyleach

💭
😃
View GitHub Profile
# hours in a year, minutes in a decade, my age in seconds, author's age.
require 'date'
class DatesAndtimes
attr_reader :minute, :day, :year, :now, :seconds, :age, :result
def initialize
@seconds = 60
@minute = 60
@day = 24
@year = 365.242
# screencast #2 b = 1 - bc var a and bar or diff objects with diff objects_id's
# screencast #2 x = 2 bc 1 plus 1 equals 2 (the value of x was changed by adding 1 to it)
# below you will find chapter 5
# => ask the user for a their frist name
# => ask the user for their middle name
# => ask the user for their last name
# => output, nice to meet you 'their name'
# => ask the user for their favorit number
#screencast #3 - Not really sure if I did this right. I have never asked for the class of a class of a string
1 => float
2 => String
3 => Range
4 => Class
5 => Class?? like I said wasn't sure what to do here, "hello".class.class is class, "hello".class is String
#screencast #4, very cool method, not sure when one would use this but I did read that it was faster then downcase
#Method number 1
"Troy" == "troy"
@troyleach
troyleach / gist:6ee7b3dcc84f9d133d33
Created January 12, 2015 05:24
bottles of beer
# => 100 bottles of beer on the wall
# => 100 bottles of beer
# => take on down, pass it around
# => 99 bottles of beer on the wall
# =>
# => 99 bottles of beer on the wall
# => 99 bottels of beer
# => take on down, pass it around
class Grandma
def talk
bye_counter = 0
puts "Lets have a talk with Grandma"
puts "Grandma is hard of hearing so you might have to SHOUT when you talk"
puts "To leave Grandma's place you have to type BYE 3 times..."
print "What would you like to say to grandma? "
while true
input = gets.chomp
if input == input.upcase
@troyleach
troyleach / gist:c3a295991f9fa9d3d9cc
Created January 12, 2015 05:26
Leap_year, the runner file
require_relative 'leap_year'
class Display
def single_year
puts "Sometimes it would be nice to know if a particular year was a leap year"
print "What year would you like to know if it was OR will be a leap year?: "
input = gets.chomp
answer = SingleLeapYear.new(input)
answer.leap_year?
answer.display
@troyleach
troyleach / gist:a69774b135521251fe48
Created January 12, 2015 05:27
leap year program
class LeapYearRange
attr_reader :years, :leap_years
def initialize(years)
@years = years
@leap_years = []
end
def leap_year?
years.each do |date|
@troyleach
troyleach / gist:899ffdd79a0a1be6e160
Created January 12, 2015 05:31
This is a runner file for bottles beer, deaf grandma leap year
#At the bottom of this file you will find a utilities file that I put together for such things as
#lines and clear screen function!!
#I am working on the last screen cast with the answer the 3 question bit! sorry it isn't done!
require_relative 'bottles_beer'
require_relative 'deaf_grandma'
require_relative 'leap_display'
require_relative 'runner_utili'
reset_screen!
@troyleach
troyleach / gist:5844a6477caf6cf78f77
Created January 12, 2015 05:46
screencast #8 guessing game
my_number = rand(50)
num_guesses = 0
loop {
print "choose a number between 1 and 6: "
guess = gets.chomp.to_i
num_guesses += 1
10.downto(0) do |number|
puts number
end
puts "BLASTOFF!"