-
-
Save karuppasamy/752755 to your computer and use it in GitHub Desktop.
Revisions
-
vonconrad revised this gist
Oct 7, 2010 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,13 +4,12 @@ def initialize end def method_missing(name, *args) unless name.to_s == "emergency" hour = Time.now.hour raise "Out for lunch" if hour >= 12 && hour < 14 end @desk.send(name, *args) end end -
nusco revised this gist
Oct 4, 2010 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,13 @@ def initialize @desk = InformationDesk.new end def method_missing(name, *args) if name.to_s == "emergency" @desk.emergency else hour = Time.now.hour raise "Out for lunch" if hour >= 12 && hour < 14 @desk.send(name, *args) end end end -
nusco revised this gist
Oct 4, 2010 . 1 changed file with 10 additions and 26 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,19 @@ class DoNotDisturb def initialize @desk = InformationDesk.new end def method_missing(method) if method.to_s == "emergency" @desk.emergency else hour = Time.now.hour raise "Out for lunch" if hour >= 12 && hour < 19 @desk.send(method) end end end # At 12:30... DoNotDisturb.new.emergency # => "emergency() called" DoNotDisturb.new.flights # ~> -:37:in `method_missing': Out for lunch (RuntimeError) -
nusco created this gist
Oct 4, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ # This class didn't change... class InformationDesk def flights # Provide flight information "flights() called" end def local_transports # Return a metro map "local_transports() called" end def hotels # Find a suitable hotel "hotels() called" end # Even more methods... end # ...but this one sure did! class DoNotDisturb def initialize @desk = InformationDesk.new end def method_missing(method) hour = Time.now.hour raise "Out for lunch" if hour == 12 || hour == 13 @desk.send(method) end end # At 10 o'clock in the morning: DoNotDisturb.new.flights # => "flights() called"