Title: ???????????? ?????????? ??????? ? ?????????????? ???????????? ?????? ???????????????? ?? ??????? Ruby
1???????????? ?????????? ??????? ? ??????????????
???????????? ?????? ???????????????? ?? ???????
Ruby
?????? ????????
Kirill.Timofeev_at_dataart.com
23.10.2008
2????????? ???????
- ?????????? ????????????????
- ????? ???????? ? ?????????? ?????????
- ??????????? ????????????? ????? Ruby
- ?????????? ??????????? ???????
- ????????-??????????????? ??????
- ???????????? ??????
- ??????????
3???????????? ??????????? ????????????????
- ???????????????? ? ?????????? ????????????
??????????? ?????????? ???????????? - ??????????? ??????????? ???????????? ????????
- ??????????? ????????????
4?????????? ??????????? ????????????????
- ??????????? ??????????? ????
- ???????? ????????? ? ???????
- ???????????? ? ??????????? ??????????? ????
5????? ???????? ? ??????? ?????????? ?????????
- ????????? ?????? ????????????????
- ?????????????? ????????? ???? ?? ?????????
????????? - ?????? ????????? ???? ? ??????????? ???????????
??????????
6???????????? ?????????? ??? ??????? ????????? ????
- ????????????? ?????? ? ???????? ? ????????????
?????????? ??????? ??? ????????????? ????????????
?????? ???????????????? - ?????????? STROBE
- ?????? Acts as State Machine ??? Ruby on Rails
7?????????? ???????????? ???????
- ?????????????? ???????????? ?? ?????? ???????
?????? ???????? ??????? ????????? - ????????????? ???????????? ??? ???????? ?????????
8???????????? ????? ????????????????
- ????????? ????????? ?????????, ?????? ??? ???????
? ??????? ?????????? ?????? ???? ?? ?????
?????????? ????????? - ????????? ????? ?????????? ? ???? ?????? (?????
eval)? - ???????????? ???????
- ????????? ????????? ??????????????? ?????
9?????????????? ????? ????????????????
- ??????? ????????? ???????? ?? ??????
????????????? ??????? - ???????????
- ???????? ???????????? ? ??????????? ?? ??????
???????? ??????????????? ??????????????
???????????? ???????? - ?????????? ????????????? ????????? ? ??????
10??????????? ????? Ruby
- ?????-?????????????
- ????????-???????????????
- ????????????
- ???????? ???????? ??????????????? ?????
11??????????? Ruby
- ?????????? ?????????-???????????????? ?????
????????? ??????? - ???????? ??????????? ????????
- ??????????? ??????? ??????? ??????????? ????????
??????????? ??????? ? ??????????? ???
12????????????? ??????????? ??????? ??? ??????????
???????
13???????????? ? ???????? ?????????
14??????? ????? ?????? ? ??????
15????????????? ?????? ?????? ? ???????
16?????????
class Main lt State def initialize container
super Main, container end end
17??????
class Opened lt Automaton def initialize name,
containernil super name, container end
def C _at_container.state Closed RT()?
end private def RT true end end
18???????
class FileAbstract lt Automaton def initialize
name, containernil super name, container
automaton Closed.new(Closed, self),
Opened.new(Opened, self)? initial Closed
end end
19???????????? ? ???????? ?????????
??????????? ?????? ????????? ? ??????? ????????
????????? ???????, ??? ????????? ?????????
???????? ???????? ??? ???????? ??? ?
????????-??????????????? ???. ?????????? ????????
?????? ????????????, ????????? ? ??????????????
????????????? ?????????????? ??????????? ?????,
??? ?? ????????? ????? ?????????????? ??????
????????? ? ????????? ???
20???????????? ? ???????? ????????? ? ???????
???????????? ??????? Ruby
class AbstractFile lt AutomatonClass automaton
do initial closed group closed do
initial main state main end
group opened do end transition c,
from gt opened, to gt closed
transition iso, from gt closed,
to gt closed, proc gt lambda
transition iso, from gt
opened, to gt opened, proc gt
lambda end end
21???????????? ? ???????? ?????????
- ???????????
- ?????????? ?????????????? ????????????
- ????????????? ?????????-???????????????? ?????
(DSL) - ??????????
- ?????? ???????? ????????????? ????????
22????????????????
class ReadFile lt AbstractFile def initialize
name, containernil super name, container
automaton ReadOpened.new(Opened, self),
ReadClosed.new(Closed, self)? end
tracer end
23??????????
- ??????????? ???????? ????? ???????? ???????????
????????-???????????????? ? ?????????????
???????? - ?????????-??????????????? ???? ????? ???????????
??? ???????? ??????? ????????-????????????????
???????.
24??????? ?? ????????! ????????