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
| articles = BrokenRecord::Table.new(:name => "articles", | |
| :db => BrokenRecord.database) | |
| articles.insert(:body => "Hey joe", :title => "blah") | |
| articles.delete(:id => 10) | |
| articles.columns | |
| (return array of hashes) | |
| articles.all | |
| (select * from articles), returns an array of hashes |
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
| module A | |
| def a | |
| end | |
| end | |
| module B | |
| def b | |
| 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
| module Person | |
| attr_accessor :email, :first_name, :last_name | |
| end | |
| class Employee | |
| include Person | |
| attr_accessor :role | |
| 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 BoundedStack | |
| OverflowError = Class.new(StandardError) | |
| invariant { data.size <= limit } | |
| def initialize(limit) | |
| self.data = [] | |
| self.limit = limit | |
| 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
| module Assertive | |
| FailedConstraint = Class.new(StandardError) | |
| class << self | |
| attr_accessor :enabled | |
| end | |
| def constraints | |
| @constraints ||= [] | |
| 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 Person | |
| alias_method :inspect, :to_s | |
| def initialize(name, email) | |
| @name = name | |
| @email = email | |
| end | |
| def to_s | |
| "#{@name} <#{@email}>" |
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 A | |
| class << self | |
| private | |
| def foo | |
| puts "bar" | |
| 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
| p((_=[gets.split,[],"+-**/"])[0].map{|__|__=~/[0-9\.]+/?_[1]<<__.to_f : _[2][__]?_[1]<<_[1].pop.send(__,_[1].pop):0}[0][0]) |
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
| puts 'Hello, and welcome to seventh grade English.' | |
| puts 'My name is Mrs. Crabbage. And your name is...?' | |
| name = gets.chomp | |
| # instead of name = 'jana' or 'Jana' do this... | |
| if name == 'jana' || name == 'Jana' | |
| puts 'Oh, YOU again. Please take a seat.' | |
| end | |
| # we usually use || instead of or, because it works |
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
| ### LESSON 2: Refactoring is not redesign | |
| https://github.com/mendicant/mendicantuniversity.org/wiki/TDD-study-session-%282012-May-03%29 | |
| code that needs redesign is not necessarily messy, just no longer correct | |
| testing eases refactoring but has a complicated effect on redesign | |
| http://devblog.avdi.org/2012/06/25/every-day-in-every-way/ | |
| A refactoring is an atomic and safe change that can be described in a sentence |