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
require 'pp' | |
my_var = "Hey There" | |
my_arr = [1, 2, 3, 4, 5, 6, 7] | |
my_json = "{ | |
id: 1, | |
title: 'Test Blog Post', | |
description: 'Here is the content', |
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
puts "What is your name?" | |
name = gets.chomp | |
if name == "dog" | |
p true | |
else | |
p false | |
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
require 'rubygems' | |
require 'decisiontree' | |
training = [ | |
[98.7, 'healthy'], | |
[99.1, 'healthy'], | |
[99.5, 'sick'], | |
[100.5, 'sick'], | |
[102.5, 'crazy sick'], | |
[107.5, 'dead'], |
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 Invoice | |
def initialize(customer, total) | |
@customer = customer | |
@total = total | |
end | |
def summary | |
puts "Invoice:" | |
puts "Customer: #{@customer}" | |
puts "Total: #{@total}" |
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 OrderReport | |
def initialize(customer:, total:) | |
@customer = customer | |
@total = total | |
end | |
end | |
class Invoice < OrderReport | |
def print_out | |
puts "Invoice" |
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 Invoice | |
def initialize(customer:, total:) | |
@customer = customer | |
@total = total | |
end | |
def summary | |
puts "Invoice" | |
puts @customer | |
puts @total |
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 Car | |
attr_accessor :doors, :color | |
def initialize(doors:, color:) | |
@doors = Array(1..doors) | |
@color = color | |
end | |
def paint_doors | |
@doors.map { |door| puts "Door #{door} painted #{@color}" } |
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 Car | |
attr_accessor :doors, :color | |
def initialize(doors:, color:) | |
@doors = Array(1..doors) | |
@color = color | |
end | |
def paint_doors | |
@doors.map { |door| puts "Door #{door} painted #{@color}" } |
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
require 'forwardable' | |
class Blog | |
def edit_post | |
puts "Post edited" | |
end | |
def delete_post | |
puts "Post removed" | |
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
# Violation | |
# require 'date' | |
# class User | |
# attr_accessor :settings, :email | |
# def initialize(email:) | |
# @email = email | |
# end | |
# end |