-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrubynotes.rb
72 lines (54 loc) · 1.05 KB
/
rubynotes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# coding: utf-8
class Ejemplo
private_class_method :new
def initialize str
puts str
end
def self.ejemplo *args
object = new *args
object
end
end
var = Thread.new "mi_hilo" do |algo|
end
fiber = Fiber.new do |hey|
puts "1#{hey}"
hey = Fiber.yield
puts "2#{hey}"
hey = Fiber.yield
puts "3#{hey}"
hey = Fiber.yield
puts "4#{hey}"
end
class StoryFlow
attr_accessor :pointer
def initialize &block
instance_eval(&block)
end
def method_missing(name, *args, &block)
if @pointer.nil?
@pointer = name.to_sym
end
definition = proc do |option|
# TODO guardar el texto en cada funcion ver como
args[1][option]
end
self.class.send(:define_method, name, definition)
end
def step option
result = send(@pointer,option)
if not result.nil?
@pointer = result
end
end
end
m = StoryFlow.new do
inicio "Erase una vez..."
0 => :fin,
1 => :interminable,
2 => :inicio
interminable "Una historia ¬ terminable"
0 => :interminable
fin "Terminable"
0 => :fin
end