Sha256: be9269a5e6c718a512478af3033169483157ffaa9c76e331ab6304840dd8d923

Contents?: true

Size: 1.23 KB

Versions: 38

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8

# Connectivity aspect of a transition.
#
module YPetri::Transition::Arcs
  # Names of upstream places.
  # 
  def domain_pp; domain.map { |p| p.name || p.object_id } end
  alias :upstream_pp :domain_pp

  # Names of downstream places.
  # 
  def codomain_pp; codomain.map { |p| p.name || p.object_id } end
  alias :downstream_pp :codomain_pp

  # Union of action arcs and test arcs.
  # 
  def arcs; domain | codomain end

  # Returns names of the (places connected to) the transition's arcs.
  # 
  def aa; arcs.map { |p| p.name || p.object_id } end

  # Marking of the domain places.
  # 
  def domain_marking; domain.map &:marking end

  # Marking of the codomain places.
  # 
  def codomain_marking; codomain.map &:marking end

  # Recursive firing of the upstream net portion (honors #cocked?).
  # 
  def fire_upstream_recursively
    return false unless cocked?
    uncock
    upstream_places.each &:fire_upstream_recursively
    fire!
    return true
  end

  # Recursive firing of the downstream net portion (honors #cocked?).
  # 
  def fire_downstream_recursively
    return false unless cocked?
    uncock
    fire!
    downstream_places.each &:fire_downstream_recursively
    return true
  end
end # module YPetri::Transition::Arcs

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
y_petri-2.2.4 lib/y_petri/transition/arcs.rb
y_petri-2.2.3 lib/y_petri/transition/arcs.rb
y_petri-2.2.2 lib/y_petri/transition/arcs.rb
y_petri-2.2.1 lib/y_petri/transition/arcs.rb
y_petri-2.2.0 lib/y_petri/transition/arcs.rb
y_petri-2.1.51 lib/y_petri/transition/arcs.rb
y_petri-2.1.50 lib/y_petri/transition/arcs.rb
y_petri-2.1.49 lib/y_petri/transition/arcs.rb
y_petri-2.1.48 lib/y_petri/transition/arcs.rb
y_petri-2.1.47 lib/y_petri/transition/arcs.rb
y_petri-2.1.46 lib/y_petri/transition/arcs.rb
y_petri-2.1.45 lib/y_petri/transition/arcs.rb
y_petri-2.1.44 lib/y_petri/transition/arcs.rb
y_petri-2.1.42 lib/y_petri/transition/arcs.rb
y_petri-2.1.40 lib/y_petri/transition/arcs.rb
y_petri-2.1.39 lib/y_petri/transition/arcs.rb
y_petri-2.1.37 lib/y_petri/transition/arcs.rb
y_petri-2.1.36 lib/y_petri/transition/arcs.rb
y_petri-2.1.35 lib/y_petri/transition/arcs.rb
y_petri-2.1.34 lib/y_petri/transition/arcs.rb