Created
October 13, 2013 20:22
-
-
Save Olefine/6967013 to your computer and use it in GitHub Desktop.
This file contains 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 Library | |
# <summary> | |
# Класс подсистемы | |
# </summary> | |
# <remarks> | |
# <li> | |
# <lu>реализует функциональность подсистемы;</lu> | |
# <lu>выполняет работу, порученную объектом <see cref="Facade"/>;</lu> | |
# <lu>ничего не "знает" о существовании фасада, то есть не хранит ссылок на него;</lu> | |
# </li> | |
# </remarks> | |
class SubsystemA | |
def a1; "Subsystem A, Method a1\n"; end | |
def a2; "Subsystem A, Method a2\n"; end | |
end | |
class SubsystemB | |
def b1; "Subsystem B, Method b1\n"; end | |
end | |
class SubsystemC | |
def c1; "Subsystem C, Method c1\n"; end | |
end | |
end | |
# <summary> | |
# Facade - фасад | |
# </summary> | |
# <remarks> | |
# <li> | |
# <lu>"знает", каким классами подсистемы адресовать запрос;</lu> | |
# <lu>делегирует запросы клиентам подходящим объектам внутри подсистемы;</lu> | |
# </li> | |
# </remarks> | |
class Facade | |
def initialize | |
@a = Library::SubsystemA.new; | |
@b = Library::SubsystemB.new; | |
@c = Library::SubsystemC.new; | |
end | |
def operation1 | |
puts "Operation 1\n" + | |
@a.a1 + | |
@a.a2 + | |
@b.b1 | |
end | |
def operation2 | |
puts "Operation 2\n" + | |
@b.b1() + | |
@c.c1() | |
end | |
end | |
facade = Facade.new | |
facade.operation1 | |
facade.operation2 | |
# Wait for user | |
gets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment