fictive 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fictive/text/compiler.rb +66 -0
- data/lib/fictive/version.rb +1 -1
- data/lib/fictive.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb279a9e70a00cbaede07005a67fd0cd2e5dfcaf
|
4
|
+
data.tar.gz: 27949c1a252d17d85da418d85bf783f74e493d01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 988cebc8374afb3af68b2c08385cfe142e509088607680f5f31886011eb1d4bb59d8bea322497b79593c7feefc7db2dce32288cdee7109d3384d9a8df50564c0
|
7
|
+
data.tar.gz: 7254383e78650b4ffd878a8221c575781d091ee926a01ce71bc7a94bc11921a821c3d3f95e8bdba4d6c4616722716af03025ee6ea3f73b60cd07d03f16b15489
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Fictive
|
2
|
+
module Text
|
3
|
+
class Compiler
|
4
|
+
def initialize(source)
|
5
|
+
@source = source
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Node
|
10
|
+
def initialize(*nodes)
|
11
|
+
@nodes = nodes
|
12
|
+
end
|
13
|
+
|
14
|
+
def evaluate
|
15
|
+
@nodes.map do |node|
|
16
|
+
result = node.evaluate
|
17
|
+
end.join
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class TextNode
|
22
|
+
def initialize(text)
|
23
|
+
@text = text
|
24
|
+
end
|
25
|
+
|
26
|
+
def evaluate
|
27
|
+
@text
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class ConditionalNode
|
32
|
+
# TODO: decide on array or explicit parameter convention
|
33
|
+
# eg: initialize(condition, consequent, alternative)
|
34
|
+
def initialize(condition, consequent)
|
35
|
+
@condition = condition
|
36
|
+
@consequent = consequent
|
37
|
+
end
|
38
|
+
|
39
|
+
def evaluate
|
40
|
+
@consequent.evaluate if @condition.evaluate_boolean
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class ExpressionNode
|
45
|
+
def initialize(expression)
|
46
|
+
@expression = expression
|
47
|
+
end
|
48
|
+
|
49
|
+
def evaluate_boolean
|
50
|
+
@expression.evaluate_boolean
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class TrueNode
|
55
|
+
def evaluate_boolean
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class FalseNode
|
61
|
+
def evaluate_boolean
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/fictive/version.rb
CHANGED
data/lib/fictive.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fictive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rickerby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03
|
11
|
+
date: 2016-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/fictive.rb
|
67
67
|
- lib/fictive/story.rb
|
68
68
|
- lib/fictive/syntax.rb
|
69
|
+
- lib/fictive/text/compiler.rb
|
69
70
|
- lib/fictive/version.rb
|
70
71
|
homepage: https://github.com/maetl/fictive
|
71
72
|
licenses:
|