Last active
March 3, 2017 07:03
-
-
Save rosylilly/8108775 to your computer and use it in GitHub Desktop.
分かった気になる DCI 、ロミオとジュリエット編 Romeo & Juliette with DCI
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
# 役者クラス | |
# | |
# say: 役者は声を発する事ができる。 | |
class Actor | |
def say(words) | |
puts words | |
end | |
end |
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 Romeo | |
def hesitate | |
say "Shall I hear more, or shall I speak at this?" | |
end | |
end |
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
# ジュリエット役 | |
# | |
# ジュリエットはロミオに問いかけ、名を捨てるように請う | |
# 1. | |
# あぁロミオ、ロミオ! どうして貴方は<わが一族の敵である>ロミオなの? | |
# 貴方の父を否定し、名前を拒否してくださいな。 | |
# お嫌ならば、私への愛を誓ってくだされば、 | |
# 私はもうキャピュレットではありませんわ | |
# 2. | |
# 私の敵なのは、貴方の名前だけ。 | |
# 貴方は貴方、モンタギューではなくても。 | |
# モンタギューって何? 手ではないし、足でもないし、 | |
# 腕でも、顔でも、その他の体の部分でもない。 | |
# あぁ、他の名前になって! | |
# 名前には、何があるというの? 私たちがバラと呼ぶものは、 | |
# 他のどんな名前で呼んでも、同じように甘く香るわ | |
module Juliette | |
def ask | |
say <<-EOS | |
O Romeo, Romeo! wherefore art thou Romeo? | |
Deny thy father and refuse thy name; | |
Or, if thou wilt not, be but sworn my love, | |
And I'll no longer be a Capulet. | |
EOS | |
end | |
def beg | |
say <<-EOS | |
Tis but thy name that is my enemy; | |
Thou art thyself, though not a Montague. | |
What's Montague? it is nor hand, nor foot, | |
Nor arm, nor face, nor any other part | |
Belonging to a man. O, be some other name! | |
What's in a name? that which we call a rose | |
By any other name would smell as sweet. | |
EOS | |
end | |
end |
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
# シーンコンテキスト | |
# | |
# 場面3 ジュリエットの部屋のバルコニーにて | |
# 1. ジュリエットが問いかける | |
# 2. 当惑するロミオ | |
# 3. 名を捨てることを請うジュリエット | |
class Scene03 | |
def initialize(romeo, juliette) | |
@romeo = romeo.extend(Romeo) | |
@juliette = juliette.extend(Juliette) | |
end | |
def execute | |
@juliette.ask | |
@romeo.hesitate | |
@juliette.beg | |
end | |
end |
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
# 役者を2人用意する | |
rosie = Actor.new | |
lilly = Actor.new | |
# 今回行うシーンはシーン3、配役は rosie がロミオで lilly がジュリエット | |
scene = Scene03.new(rosie, lilly) | |
# 演目を行う | |
scene.execute | |
# 今回は役を module で実装しているが、この場合シーン終了後に取り外せないので、 | |
# 現実的には wrapper class の方が良い。 unextend などを使う場合はこの限りではない。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment