This file contains 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 is_obstructed?(x1, y1, x2, y2) | |
is_obstructed_vertically?(x1, y1, x2, y2) || | |
is_obstructed_horizontally?(x1, y1, x2, y2) || | |
is_obstructed_diagonally?(x1, y1, x2, y2) | |
end | |
def is_obstructed_vertically?(x1, y1, x2, y2) | |
end | |
This file contains 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
## Downcase, Upcase, Capitalize | |
name = "Peter" | |
name.upcase # => "PETER" | |
name.downcase # => "peter" | |
name = "pEtEr" | |
name.capitalize # => "Peter" | |
## Characters | |
name = "Peter" |
This file contains 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 Email | |
attr_accessor :subject, :date, :from | |
def initialize(subject, date, from) | |
@subject = subject | |
@date = date | |
@from = from | |
end | |
This file contains 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 Person | |
attr_accessor :name, :id, :address | |
def initialize(name, id, address) | |
@name = name | |
@id = id | |
@address = address | |
end | |
def where_do_you_live |
This file contains 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
FactoryBot.define do | |
factory :user do | |
sequence :email do |n| | |
"sampleEmails#{n}@gmail.com" | |
end | |
password "secretPassword" | |
password_confirmation "secretPassword" | |
end |
This file contains 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 Game < ActiveRecord::Base | |
# all the associations, etc. | |
after_create :populate_board! | |
def populate_board! | |
# this should create all 32 pieces with their initial X/Y coordinates. | |
end | |
end |
This file contains 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 Collatz | |
def initialize(n) | |
@current_number = n | |
@sequence = [] | |
end | |
def compute_next_collatz | |
@sequence << @current_number |