Skip to content

Instantly share code, notes, and snippets.

View kiefer136's full-sized avatar

Kiefer kiefer136

  • Canada
View GitHub Profile
--- question: how self refers to different objects depending on where it is in a Ruby program ---
Self refers to different objects by allowing you to access the class self is called upon. If you were to have a self.method inside a class named 'Person' instead of having to write Person.method, you can use self to call Person. Self calls its parent class if its inside a method and prints the methods class name. If self is called outside of a method in the same class, it will print the class, although it will give it an object value aswell.
@kiefer136
kiefer136 / contact.csv
Last active April 7, 2016 16:15
contact_list
1 Kiefer Johnson Kiefer136@hotmail.com
2 ben byer ben@.com
3 ryan goodbrew ryan@.com
4 Steve Henderson hevets@mail.com
5 Don Burks Don@lighthouselabs.ca
6 Khurram Virani kvirani@lighthouselabs.ca
7 Dominos Pizza dpiza@mails.co
require_relative "./animalmodule"
class Animal
attr_reader :breath_air
attr_reader :num_legs
def initialize
@breath_air = true
@num_legs = 0
@kiefer136
kiefer136 / file-analysis.txt
Last active April 4, 2016 20:56
rubybastards
jpeg 1 2944429
deb 4 15856384
mp4 2 174921790
zip 2 5736305
pdf 1 194097
rb 3 749
js 1 97244
rpm 1 4256
jpg 1 8184
mp3 1 5113626
@kiefer136
kiefer136 / counting.rb
Last active March 30, 2016 23:31
character counting
def count_letters(string)
letters = Hash.new(0)
string_split = string.split('')
for x in string_split do
if x != ' '
letters[x] += 1
end
end
letters
end
@kiefer136
kiefer136 / rooby
Created March 29, 2016 19:02
My Ruby Kiefer Johnson
[1] pry(main)> 5 + 10
=> 15
[2] pry(main)> REPL
NameError: uninitialized constant REPL
from (pry):2:in `__pry__'
[3] pry(main)> def say_hi(name)
[3] pry(main)* def say_hi(Josh)
[3] pry(main)*
[3] pry(main)> def say_hi(name)
[3] pry(main)* "hi #{name}"