Skip to content

Instantly share code, notes, and snippets.

View mmower's full-sized avatar
💭
Writing code

Matt Mower mmower

💭
Writing code
View GitHub Profile
@mmower
mmower / gist:11041
Created September 16, 2008 15:04 — forked from wilson/gist:11036
# Used to modify the relationship tags applied to the specified contact
#
# PUT /users/bob/contacts/alice/tags?friend=t&family=f
#
# Sets the tags on the relationship that 'bob' has with 'alice' to be 'friend' and not 'family'
#
def tags
@contact = user.contacts.with_login( params[:id] )
@relationship = user.relationships.with( @contact )
@relationship.set( tags_from_params( params ) )
# ruby beginner elevator program
# We might break this stuff up into more classes as the need to separate state and
# behaviour of different entities emerges, for now we keep it simple and imagine
# the state to be that of the building as a whole.
#
class Building
GROUND_FLOOR = 0
# ruby beginner elevator program
# We might break this stuff up into more classes as the need to separate state and
# behaviour of different entities emerges, for now we keep it simple and imagine
# the state to be that of the building as a whole.
#
# new code added by calvin... work in progress, still figuring how to make it all work
class Building
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
IBOutlet NSTextField *clockInTextField;
IBOutlet NSTextField *clockOutTextField;
IBOutlet NSTextField *resultsField;
IBOutlet NSTextField *payRateField;
class Person
attr_accessor :name, :age, :gender
end
person_instance = Person.new
person_instance.name = 'robert'
person_instance.age = 52
person_instance.gender = 'male'
x = "test"
y = " string"
z = x + y
puts"#{x} + #{y} = #{z}"
require 'test/unit'
class Calculator
def equation(val1, val2)
result = val1 + val2
return result
end
end
# Okay so the only real point here is one of style. In Ruby it's not necessary
# to use 'return'. By default a method returns the value of the last expression
# evaluated. So your method can be rewritten
class Album
def info(val1, val2, val3)
val1 + ", " + val2 + ", " + "#{val3}"
end
end
# It's not at all clear what is going on here. First, I can make the assumption
# that val1 is an album name & val2 is the band. But val3? No clue. How about
def info( album, band, whatever_this_is )
describe "Hospital Patient Chart" do
it "should have heart rate information" do
# heart rate information is numeric
# so it should be represented as a number
# it's implied that it's beats per minute
# (unless you're going to be storing it in
# some other format elsewhere)
HospitalPatientChart.new( 75 ).heart_rate.should == 75
end
end
describe "Hospital Patient Chart" do
it "should have heart rate information" do
# heart rate information is numeric
# so it should be represented as a number
# it's implied that it's beats per minute
# (unless you're going to be storing it in
# some other format elsewhere)
HospitalPatientChart.new( 75 ).heart_rate.should == 75
end
end