petri 0.0.4 → 0.0.5

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: 0ca89d14cc30bfaab2ac80857c35bc28246cb5ad
4
- data.tar.gz: 5746ed6a807848ea27a9cfa20a8a16c0858df871
3
+ metadata.gz: f5711021e572160e00d1d141aaeeb47da66274cf
4
+ data.tar.gz: '058e4c797e75c1ec1c47ac0941f52152c539b8cb'
5
5
  SHA512:
6
- metadata.gz: 979788786152fefb1c61263899c81542f7d345a3597bada3aea9238c230f1dea07e66389c01a9b318b6de320a5c11a3794c3c696b732666d0ae41ad2807b6fc9
7
- data.tar.gz: 2df35daae13ec0588d6707362b1bab6cacc596cba9c54f580bcaf129d0904b941a33960fc9e01577826ac5ff337e088593a0a377ba23292839bccc164e286657
6
+ metadata.gz: 771dedaff51498bcbb60b923860727be7071fb285038aef804be7db25aea38af0982749c3cf04a84582dc09f660c97b5414de9d5cdf46c82578485ae4dd30958
7
+ data.tar.gz: 1960751dfdd05e484516b99dfab8e021737c18e94cf22a3958c82a27385c3ffecee9c7c4911b3282357c291dc2a9dfc54067de74b39f816a508af6aa6fbc2455
data/lib/petri/arc.rb CHANGED
@@ -2,8 +2,8 @@ module Petri
2
2
  class Arc < Element
3
3
  attr_reader :from_node, :to_node, :type
4
4
 
5
- def initialize(net, from: nil, to: nil, type: nil, guid: nil, production_rule: nil, guard: nil)
6
- super(net, {guid: guid, production_rule: production_rule, guard: guard})
5
+ def initialize(net, from: nil, to: nil, type: nil, guid: nil, production_rule: nil, guard: nil, timer_rule: nil)
6
+ super(net, {guid: guid, production_rule: production_rule, guard: guard, timer_rule: timer_rule})
7
7
  @from_node = from
8
8
  @to_node = to
9
9
  @type = type.try(:to_sym) || :regular
@@ -29,6 +29,10 @@ module Petri
29
29
  data[:guard]
30
30
  end
31
31
 
32
+ def timer_rule
33
+ data[:timer_rule]
34
+ end
35
+
32
36
  def normalized_guard
33
37
  self.class.normalize_guard(guard)
34
38
  end
@@ -52,15 +52,15 @@ module Petri
52
52
  # @param to_guid [String]
53
53
  # @param type [String]
54
54
  # @param production_rule [String, nil]
55
- def add_arc(guid: nil, from_guid: , to_guid: , type: , production_rule: nil, guard: nil)
55
+ def add_arc(guid: nil, from_guid: , to_guid: , type: , production_rule: nil, guard: nil, timer_rule: nil)
56
56
  from_node = node_by_guid(from_guid)
57
57
  to_node = node_by_guid(to_guid)
58
58
 
59
59
  if type == 'test'
60
- @arcs << Arc.new(self, from: from_node, to: to_node, type: :regular, guid: guid, guard: guard)
60
+ @arcs << Arc.new(self, from: from_node, to: to_node, type: :regular, guid: guid, guard: guard, timer_rule: timer_rule)
61
61
  @arcs << Arc.new(self, from: to_node, to: from_node, type: :regular, guid: guid)
62
62
  else
63
- @arcs << Arc.new(self, from: from_node, to: to_node, type: type.try(:to_sym), guid: guid, production_rule: production_rule, guard: guard)
63
+ @arcs << Arc.new(self, from: from_node, to: to_node, type: type.try(:to_sym), guid: guid, production_rule: production_rule, guard: guard, timer_rule: timer_rule)
64
64
  end
65
65
  end
66
66
 
@@ -91,7 +91,8 @@ module Petri
91
91
  add_arc(from_guid: arc['from_guid'],
92
92
  to_guid: transition.guid,
93
93
  type: front_arc_type,
94
- guard: arc['guard'])
94
+ guard: arc['guard'],
95
+ timer_rule: arc['timer_rule'])
95
96
 
96
97
  add_arc(from_guid: transition.guid,
97
98
  to_guid: arc['from_guid'],
@@ -156,6 +157,7 @@ module Petri
156
157
  to_guid: data['to_guid'],
157
158
  type: data['type'],
158
159
  production_rule: data['production_rule'],
160
+ timer_rule: data['timer_rule'],
159
161
  guard: data['guard'])
160
162
  end
161
163
  end
@@ -37,6 +37,14 @@ module Petri
37
37
  ingoing_arcs.select { |arc| arc.guard.present? }
38
38
  end
39
39
 
40
+ def timer_arc
41
+ input_arcs.find { |arc| arc.timer_rule.present? }
42
+ end
43
+
44
+ def timer_rule
45
+ timer_arc.try!(:timer_rule)
46
+ end
47
+
40
48
  def inspect
41
49
  "Petri::Transition<#{identifier}>"
42
50
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Petri
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Zinin (einzige)
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  version: '0'
54
54
  requirements: []
55
55
  rubyforge_project:
56
- rubygems_version: 2.5.1
56
+ rubygems_version: 2.6.8
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: Moves tokens around