ocarina_of_time 1.0.0 → 1.0.1

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: c76b5c32fdda58e5ba617450ad0f9acee53b290a
4
- data.tar.gz: caddfbedba3fe902dce0c19604a71388cd2633d5
3
+ metadata.gz: 9b8f6353a6d7086e4b1f5ee75636393fa92fab8e
4
+ data.tar.gz: ff95bfcd93e4446b745bce5fc75711005ce7f159
5
5
  SHA512:
6
- metadata.gz: 297211847d7ab989b49df4ccdaa6fcf8955ea1abef018dcded9b0b0255a9706d8573e399fcadfd1bf332839b3f6e6bdfb725968db9d5c2210a8e86b4c89f7185
7
- data.tar.gz: 581dd32dc21fa8bad047554d9dcdeed68207a0f6f2c072c108797014ba7cc62256e44545b3b724c4b7ffdc2ec9d2147e286461acf5ab48c7f0fec099668af44b
6
+ metadata.gz: 8e0f8f63b34f62f7674354382002f98d6f452408e994f94441da35a6f3156b23ef34c668ca5de382c7bd4c43ff39021be2e77b0185968cb27aa5f06b987a29e8
7
+ data.tar.gz: aab1b27442879ce34c190ccca4a001b52accda26e8666897878246af4da327e709338a0ca8d0151fa7db94a386ece6a53553e8198a7fc9829b911be3e8672dc2
data/README.md CHANGED
@@ -16,6 +16,8 @@ Play this song near a blue Time Block.
16
16
 
17
17
  ## Usage
18
18
 
19
+ I'm still sort of fleshing out some things. So, I'll update thing as they change.
20
+
19
21
  ```ruby
20
22
  require 'ocarina_of_time'
21
23
 
@@ -24,30 +26,31 @@ timeline = OcarinaOfTime::Timeline.new
24
26
  # beginning of time
25
27
  timeline.beginning
26
28
  # => 2017-02-21 10:10:16 -0500
27
-
28
29
  # check for beginning of time
29
30
  timeline.beginning?
30
31
 
31
- # end of time
32
32
  timeline.ending
33
33
  # => false
34
-
35
- # check for end of time
36
34
  timeline.ending?
37
35
  # => false
38
-
39
- # set beginning of end of time
40
- timeline.ending = Time.now
41
-
36
+ # set end of time
37
+ timeline.ending(Time.now)
42
38
  timeline.ending?
43
39
  # => true
44
-
45
40
  timeline.ending
46
41
  # => 2017-02-21 10:15:45 -0500
42
+
43
+ # or, just make it flexible
44
+ timeline.flex!
45
+
47
46
  ```
48
47
 
49
48
  ## Timeline
50
- A timeline is a way of displaying a list of events in chronological order, sometimes described as a project artifact. Timelines can use any time scale, depending on the subject and data. Most timelines use a linear scale, where a unit of distance is equal to a set amount of time.
49
+ A timeline is a way of displaying a list of events in chronological order, sometimes described as a project artifact ( an event ). Timelines can use any time scale, depending on the subject and data. Most timelines use a linear scale, where a unit of distance is equal to a set amount of time. Or, well, at least that is what Wikipedia says.
50
+
51
+ ### The Short and Simple
52
+
53
+ A timeline has a beginning ( sometimes ) and an ending ( sometimes ). You can have a flexible timeline where, as events are added, the beginning and ending points in time will be determined by the actual events themselve.
51
54
 
52
55
  ```ruby
53
56
  # will return a unique id number for the timeline event
@@ -0,0 +1,62 @@
1
+ $: << File.expand_path("../../lib", __FILE__)
2
+ require "ocarina_of_time"
3
+ require "pry"
4
+
5
+ # create timeline
6
+ timeline = OcarinaOfTime::Timeline.new
7
+
8
+ # flexible timeline
9
+ timeline.flex!
10
+
11
+ # add events ( roughly =~ 2 seconds from eachother )
12
+ ["Example 1", "Example 2", "Example 3"].each do |example|
13
+ sleep 2
14
+ timeline.events.add(label: example, time: Time.now)
15
+ end
16
+
17
+ # check flexbility
18
+ timeline.flex?
19
+ # => true
20
+
21
+ # Some quick examples ( not everything )
22
+
23
+ timeline.events.times
24
+ # => [2017-02-21 20:43:11 -0500, 2017-02-21 20:43:13 -0500, 2017-02-21 20:43:15 -0500]
25
+
26
+ timeline.events.ids
27
+ # => ["69ba109e-15cb-44cc-b541-042cc1cdaf82", "5e4dc4ff-c263-4365-ab3a-c37b2c11af66", "11801833-ba11-47c8-aef1-b1d621e461dd"]
28
+
29
+ timeline.events.dates
30
+ # => [#<Date: 2017-02-21 ((2457806j,0s,0n),+0s,2299161j)>]
31
+
32
+ timeline.events
33
+ # => #<OcarinaOfTime::Events:0x007f8fe847d590
34
+ # @all=
35
+ # [#<OcarinaOfTime::Event:0x007f8fe847d428
36
+ # @data=
37
+ # #<struct Struct::EventData
38
+ # id="69ba109e-15cb-44cc-b541-042cc1cdaf82",
39
+ # label="Example 1",
40
+ # tags=#<Set: {}>,
41
+ # time=2017-02-21 20:43:11 -0500,
42
+ # created=2017-02-21 20:43:11 -0500,
43
+ # value=false>>,
44
+ # #<OcarinaOfTime::Event:0x007f8fe847d040
45
+ # @data=
46
+ # #<struct Struct::EventData
47
+ # id="5e4dc4ff-c263-4365-ab3a-c37b2c11af66",
48
+ # label="Example 2",
49
+ # tags=#<Set: {}>,
50
+ # time=2017-02-21 20:43:13 -0500,
51
+ # created=2017-02-21 20:43:13 -0500,
52
+ # value=false>>,
53
+ # #<OcarinaOfTime::Event:0x007f8fe847cd98
54
+ # @data=
55
+ # #<struct Struct::EventData
56
+ # id="11801833-ba11-47c8-aef1-b1d621e461dd",
57
+ # label="Example 3",
58
+ # tags=#<Set: {}>,
59
+ # time=2017-02-21 20:43:15 -0500,
60
+ # created=2017-02-21 20:43:15 -0500,
61
+ # value=false>>]>
62
+
@@ -3,9 +3,7 @@ module OcarinaOfTime
3
3
  # Respresent the logic of a Timeline.
4
4
  # @author Kent 'picat' Gruber
5
5
  class Timeline
6
-
7
- attr_accessor :beginning
8
- attr_accessor :ending
6
+ # Access events.
9
7
  attr_accessor :events
10
8
 
11
9
  # Create a new **Timeline** object.
@@ -15,12 +13,42 @@ module OcarinaOfTime
15
13
  # @option args [Time] :end ending point in time (default: false)
16
14
  # @return [void]
17
15
  def initialize(args={})
18
- @beginning = args[:begin] || Time.now
19
- @ending = args[:end] || false
20
- @flex = false # have a rigid timeline
16
+ if args[:flex]
17
+ @flex = true
18
+ else
19
+ @flex = false # have a rigid timeline
20
+ @beginning = args[:begin] || Time.now
21
+ @ending = args[:end] || false
22
+ end
21
23
  @events = Events.new
22
24
  end
23
25
 
26
+ # Either get the beinning of the timline or set it.
27
+ def beginning(set=false)
28
+ if set
29
+ @beginning = set unless @flex
30
+ else
31
+ if @flex
32
+ @events.by(newest: true).first
33
+ else
34
+ @beginning
35
+ end
36
+ end
37
+ end
38
+
39
+ # Either get the ending of the timline or set it.
40
+ def ending(set=false)
41
+ if set
42
+ @ending = set unless @flex
43
+ else
44
+ if @flex
45
+ @events.by(oldest: true).first
46
+ else
47
+ @ending
48
+ end
49
+ end
50
+ end
51
+
24
52
  # Turn on a flexible timeline, where events will change the potential
25
53
  # range of the timeline. If a beginning is set, an unflexible timeline
26
54
  # will not allow any new events to be set before that time. A flexible timeline
@@ -31,6 +59,13 @@ module OcarinaOfTime
31
59
  on ? @flex = true : @flex = false
32
60
  end
33
61
 
62
+ # Yolo swag, lets just turn the flex on.
63
+ #
64
+ # @return[void]
65
+ def flex!
66
+ @flex = true
67
+ end
68
+
34
69
  # Check if the Timeline is flexible or not.
35
70
  #
36
71
  # @return[Boolean]
@@ -43,7 +78,15 @@ module OcarinaOfTime
43
78
  #
44
79
  # @return[Boolean]
45
80
  def ending?
46
- @ending ? true : false
81
+ if @flex
82
+ if @events.data.all.empty?
83
+ false
84
+ else
85
+ true
86
+ end
87
+ else
88
+ @ending ? true : false
89
+ end
47
90
  end
48
91
 
49
92
  # Check if there's currently a beginning of time
@@ -51,7 +94,15 @@ module OcarinaOfTime
51
94
  #
52
95
  # @return[Boolean]
53
96
  def beginning?
54
- @beginning ? true : false
97
+ if @flex
98
+ if @events.data.all.empty?
99
+ false
100
+ else
101
+ true
102
+ end
103
+ else
104
+ @beginning ? true : false
105
+ end
55
106
  end
56
107
 
57
108
  # Get the difference in time between +two+ points in +time+.
@@ -1,3 +1,3 @@
1
1
  module OcarinaOfTime
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocarina_of_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kent Gruber
@@ -72,6 +72,7 @@ files:
72
72
  - bin/console
73
73
  - bin/setup
74
74
  - examples/debug.rb
75
+ - examples/timeline.rb
75
76
  - lib/ocarina_of_time.rb
76
77
  - lib/ocarina_of_time/event.rb
77
78
  - lib/ocarina_of_time/events.rb