This file contains hidden or 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
| category_attributes = [{name: 'Wrecks/Artifacts', image: Rails.root.join('/assets/images/categories/Wrecks.jpg')}, | |
| {name: 'Caves', image: Rails.root.join('/app/assets/images/categories/Caves.jpg')}, | |
| {name: 'Drift', image: Rails.root.join('/app/assets/images/categories/Drift.jpg')}, | |
| {name: 'Walls', image: Rails.root.join('/app/assets/images/categories/Walls.jpg')}, | |
| {name: 'Whales & Sharks', image: Rails.root.join('/app/assets/images/categories/Sharks.jpg')}, | |
| {name: 'Macro/Corals', image: Rails.root.join('/app/assets/images/categories/Corals.jpg')}, | |
| {name: 'Manta Rays', image:Rails.root.join('/app/assets/images/categories/Manta.jpg')}, | |
| {name: 'Night', image: Rails.root.join('/app/assets/images/categories/Night.jpg')}, | |
| {name: 'Turtles', image: Rails.root.join('/app/assets/images/categories/Turtles.jpg')}, | |
| {name: 'Schools of Fish', image: Rails.root.join('/app/assets/images/categories/Fish.jpg')}] |
This file contains hidden or 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 recursion(number) | |
| if number == 1 | |
| number | |
| else | |
| number * recursion(number - 1) | |
| end | |
| end |
This file contains hidden or 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 BankAccount | |
| attr_reader :account_type, :starting_balance, :transactions_array | |
| def initialize(account_type, starting_balance, transactions_array = []) | |
| @account_type = account_type | |
| @starting_balance = starting_balance | |
| @transactions_array = transactions_array | |
| end |
This file contains hidden or 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 Square | |
| attr_reader :side | |
| def initialize(side) | |
| @side = side | |
| end | |
| def area | |
| side * side |
This file contains hidden or 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 Whiteboard | |
| attr_accessor :contents | |
| def initialize(contents = []) | |
| @contents = contents | |
| end | |
| def erase(contents) | |
| @contents.delete(contents.length) | |
| end |
This file contains hidden or 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 Card | |
| def initialize(rank, suit) | |
| @suit = suit | |
| @rank = rank | |
| end | |
| def rank | |
| @rank | |
| end | |
This file contains hidden or 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 | |
| def initialize(color, owner, cylinders) | |
| @color = color | |
| @owner = owner | |
| @cylinders = cylinders | |
| end | |
| def color | |
| @color | |
| end |
This file contains hidden or 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 Television | |
| def initialize(brand, model) | |
| @brand = brand | |
| @model = model | |
| end | |
| end | |
| class TelevisionChannel | |
| def initialize(name, channel_number) | |
| @name = name |
This file contains hidden or 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 Card | |
| def initialize(rank = nil, suit = nil) | |
| if suit.nil? | |
| @suit = ['♠', '♣', '♥', '♦'].sample | |
| else | |
| @suit = suit | |
| end | |
| if rank.nil? | |
| @rank = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'].sample | |
| else |
This file contains hidden or 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
| scores = [75, 100, 85, 65, 84, 87, 95] | |
| def average(array) | |
| total = 0 | |
| array.each {|i| total += i} | |
| total/array.length | |
| end |
NewerOlder