Skip to content

Instantly share code, notes, and snippets.

View iseitz's full-sized avatar
💭
www.linkedin.com/in/irina-karchebnaya-seitz

iseitz iseitz

💭
www.linkedin.com/in/irina-karchebnaya-seitz
View GitHub Profile
@iseitz
iseitz / card.rb
Created November 6, 2017 18:33
Creating a card class with specific rank and suit, then create a hand of several cards and checking if it has any face cards
class PlayingCard
attr_accessor :rank, :suite
def initialize (rank, suite)
@rank = rank
@suite = suite
end
def face_card?
['K', 'Q', 'J'].include?(@rank)
end
@iseitz
iseitz / Ruby_trick
Created October 27, 2017 17:28
Ruby triks
animal = "cat"
class << animal
def speak
puts "miow"
end
end
animal.speak
#self is assigned to the object and then the method is found for this class of the object via Singleton (unique methods table). One to the right, one up
@iseitz
iseitz / the maximum value in the hash - Ruby
Last active September 29, 2017 20:43
Find the maximum value in the hash - Ruby (vowels, words count, temperature etc)
max = -1
vowels_hash.each do |vowel, frequency|
if frequency > max
max = frequency
end
end