Created
October 16, 2012 00:25
-
-
Save rondale-sc/3896565 to your computer and use it in GitHub Desktop.
try_and_try_again
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 Project | |
attr_reader :supervisor | |
# assume supervisor looks like: | |
# ["Harry", "Henderson", "[email protected]"] | |
def initialize(supervisor) | |
@supervisor = supervisor | |
end | |
def display_name | |
if supervisor | |
supervisor[0] + ", " + supervisor[1] # yuck | |
else | |
"No supervisor assigned." | |
end | |
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 Project | |
attr_reader :supervisor | |
# assume supervisor looks like: | |
# Supervisor.new("Harry", "Henderson", "[email protected]") | |
def initialize(supervisor) | |
@supervisor = supervisor | |
end | |
end | |
Supervisor = Struct.new(:first_name, :last_name, :email) do | |
def display_name | |
if !first_name.nil? || !last_name.nil? | |
first_name + ", " + last_name | |
else | |
"No supervisor assigned." | |
end | |
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
NullSupervisor = Struct.new() do | |
def display_name | |
"No supervisor assigned." | |
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 Project | |
attr_reader :supervisor | |
# assume supervisor looks like: | |
# Supervisor.new("Harry", "Henderson", "[email protected]") | |
def initialize(supervisor=NullSupervisor.new) | |
@supervisor = supervisor | |
end | |
end | |
Supervisor = Struct.new(:first_name, :last_name, :email) do | |
def display_name | |
first_name + ", " + last_name | |
end | |
end | |
NullSupervisor = Struct.new() do | |
def display_name | |
"No supervisor assigned." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment