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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a6b8f48c6c24d464a8ff938d1fbe6c715e4d8fa
4
- data.tar.gz: d2a0f159d2aebb37217778f3bb15febe4adec0ca
3
+ metadata.gz: fb279a9e70a00cbaede07005a67fd0cd2e5dfcaf
4
+ data.tar.gz: 27949c1a252d17d85da418d85bf783f74e493d01
5
5
  SHA512:
6
- metadata.gz: 536096df4ca0e146a62710ee1b2c2bc8326e6001aa29596d5f1c930bfef88932a65064c816ce93160e680dfc9e3f245fe5eda7b4118b3231b4da1df9514a5962
7
- data.tar.gz: e2b6c266cc59baf7f608c81822c71ce1faa8046d08486d3c00796578f44a6a8e9b158cfe92f6f2af0ab6396990bac2fdc71d989b795a79c901a5ae223ae208f9
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
@@ -1,3 +1,3 @@
1
1
  module Fictive
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
data/lib/fictive.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require_relative 'fictive/version'
2
2
  require_relative 'fictive/story'
3
3
  require_relative 'fictive/syntax'
4
+ require_relative 'fictive/text/compiler'
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.2
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-31 00:00:00.000000000 Z
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: