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 Tweet < ActiveRecord::Base | |
| scope :recent, -> { order('created_at desc').limit(4) } | |
| scope :graveyard, -> { where(show_location: true, location: "graveyard") } | |
| 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
| { "appointment": { "title": "Ms. Kitty Hairball Treatment", "cankelled": false, "identifer": 1 } |
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 Game | |
| attr_reader :name, :tags | |
| def initialize(name) | |
| @name = name | |
| @tags = [] | |
| end | |
| def year(value) | |
| @year = value |
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
| LIBRARY = Library.new | |
| def add_game(name, system = nil, year = nil, &block) | |
| game = Game.new(name) | |
| game.system(system) if system | |
| game.year(year) if year | |
| game.instance_eval(&block) if block_given? | |
| LIBRARY.add_game(game) | |
| 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
| add_game "Super Metroid", "SNES", 1994 | |
| with_game "Super Metroid" do | |
| play # we expect this to raise an exception | |
| 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 Game | |
| attr_reader :name, :tags | |
| def initialize(name) | |
| @name = name | |
| @year = nil | |
| @system = nil | |
| @tags = [] | |
| 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 Library | |
| def initialize | |
| @games = [] | |
| end | |
| def add_game(game) | |
| @games << game | |
| end | |
| def find_by_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
| add_game "Civilization" do | |
| system "PC" | |
| year 1991 | |
| strategy # These two method names | |
| turn_based # should become tags | |
| end | |
| with_games_tagged "strategy" do | |
| print_details | |
| 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
| LIBRARY = Library.new | |
| def add_game(name, system = nil, year = nil, &block) | |
| game = Game.new(name) | |
| game.system(system) if system | |
| game.year(year) if year | |
| game.instance_eval(&block) if block_given? | |
| LIBRARY.add_game(game) | |
| 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
| add_game "Civilization" do | |
| system "PC" | |
| year 1991 | |
| strategy # These two method names | |
| turn_based # should become tags | |
| end |
NewerOlder