fictive 0.0.3 → 0.0.4

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: fb279a9e70a00cbaede07005a67fd0cd2e5dfcaf
4
- data.tar.gz: 27949c1a252d17d85da418d85bf783f74e493d01
3
+ metadata.gz: 88bfc254e92afc19fed8f8e93619ec339b54a2e6
4
+ data.tar.gz: 64fb1b355aa5c51c7dccf384661d0b1714b1a5df
5
5
  SHA512:
6
- metadata.gz: 988cebc8374afb3af68b2c08385cfe142e509088607680f5f31886011eb1d4bb59d8bea322497b79593c7feefc7db2dce32288cdee7109d3384d9a8df50564c0
7
- data.tar.gz: 7254383e78650b4ffd878a8221c575781d091ee926a01ce71bc7a94bc11921a821c3d3f95e8bdba4d6c4616722716af03025ee6ea3f73b60cd07d03f16b15489
6
+ metadata.gz: 30dd9a864867c4dadd1f8e0793d897891fcd114f5282e115fed818c3df1c54daf78830573b2bb1c2fed8346a22b0bf061c09cb4ba074a987616c431819de4a28
7
+ data.tar.gz: bc5308f29f24d21fd8a1bc29c842e9c2e4b8dcf1943614b1655f7e4e319b9c2b6a74bada7dd2216e77b8b64ed59c783575c2fb5e6a4919f824e8156cfae5aa13
@@ -0,0 +1,11 @@
1
+ module Fictive
2
+ class Choice
3
+ def initialize(metadata)
4
+ @metadata = metadata
5
+ end
6
+
7
+ def id
8
+ @metadata.fetch(:id)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ module Fictive
2
+ class Passage
3
+ attr_reader :text
4
+
5
+ def initialize(metadata, text)
6
+ @metadata = metadata
7
+ @text = text
8
+ end
9
+
10
+ def id
11
+ @metadata.fetch(:id)
12
+ end
13
+
14
+ def choices
15
+ @metadata.fetch(:choices, [])
16
+ end
17
+ end
18
+ end
data/lib/fictive/story.rb CHANGED
@@ -1,59 +1,32 @@
1
1
  module Fictive
2
- class Scene
3
- attr_reader :passage
4
-
5
- def initialize(metadata, passage)
6
- @metadata = metadata
7
- @passage = passage
8
- end
9
-
10
- def path
11
- @metadata.fetch(:path)
12
- end
13
-
14
- def choices
15
- @metadata.fetch(:choices, [])
16
- end
17
- end
18
-
19
- class Choice
20
- def initialize(metadata)
21
- @metadata = metadata
22
- end
23
-
24
- def path
25
- @metadata.fetch(:path)
26
- end
27
- end
28
-
29
2
  class Story
30
3
  def self.demo
31
4
  self.new([
32
- Scene.new({path: 'hello', choices: [Choice.new({path: 'goodbye'})]}, 'Hello world'),
33
- Scene.new({path: 'goodbye'}, 'Goodbye world')
5
+ Passage.new({id: 'hello', choices: [Choice.new({id: 'goodbye'})]}, 'Hello world'),
6
+ Passage.new({id: 'goodbye'}, 'Goodbye world')
34
7
  ])
35
8
  end
36
9
 
37
- def initialize(scenes)
38
- @scenes = scenes
39
- @scenes_index = {}
40
- @scenes.each_with_index do |scene, id|
41
- @scenes_index[scene.path] = id
10
+ def initialize(passages)
11
+ @passages = passages
12
+ @passages_index = {}
13
+ @passages.each_with_index do |passage, id|
14
+ @passages_index[passage.id] = id
42
15
  end
43
16
 
44
17
  @index = 0
45
18
  end
46
19
 
47
20
  def has_next?
48
- !@scenes.at(@index).nil? && !@scenes.at(@index + 1).nil?
21
+ !@passages.at(@index).nil? && !@passages.at(@index + 1).nil?
49
22
  end
50
23
 
51
24
  def next
52
- @scenes.at(@index)
25
+ @passages.at(@index)
53
26
  end
54
27
 
55
- def choose_path(path)
56
- @index = @scenes_index[path]
28
+ def choose_path(id)
29
+ @index = @passages_index[id]
57
30
  end
58
31
  end
59
32
  end
@@ -1,3 +1,3 @@
1
1
  module Fictive
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
data/lib/fictive.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require_relative 'fictive/version'
2
2
  require_relative 'fictive/story'
3
+ require_relative 'fictive/choice'
4
+ require_relative 'fictive/passage'
3
5
  require_relative 'fictive/syntax'
4
6
  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.3
4
+ version: 0.0.4
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-04-03 00:00:00.000000000 Z
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -64,6 +64,8 @@ files:
64
64
  - README.md
65
65
  - fictive.gemspec
66
66
  - lib/fictive.rb
67
+ - lib/fictive/choice.rb
68
+ - lib/fictive/passage.rb
67
69
  - lib/fictive/story.rb
68
70
  - lib/fictive/syntax.rb
69
71
  - lib/fictive/text/compiler.rb