Module: YPetri::Simulation::MarkingClamps::Access

Defined in:
lib/y_petri/simulation/marking_clamps/access.rb

Instance Method Summary collapse

Instance Method Details

#marking_clamp(clamped_place) ⇒ Object

Identification of a single marking clamp. Expects a single clamped place or place id and returns the value of its clamp.



29
30
31
# File 'lib/y_petri/simulation/marking_clamps/access.rb', line 29

def marking_clamp( clamped_place )
  marking_clamps( clamped_place ).first
end

#marking_clamps(*clamped_places) ⇒ Object Also known as: clamps

Expects an arbitrary number of arguments identifying clamped places, whose marking clamps are then returned. If no arguments are given, acts as a getter of @marking_clamps instance variable.



19
20
21
22
23
# File 'lib/y_petri/simulation/marking_clamps/access.rb', line 19

def marking_clamps *clamped_places
  return Marking_clamps( clamped_places ) unless clamped_places.empty?
  @marking_clamps or
    fail TypeError, "+@marking_clamps+ not instantiated yet!"
end

#Marking_clamps(array) ⇒ Object Also known as: marking_Clamps

Expects a single array of clamped places or place ids, and returns an array of their clamp values.



10
11
12
# File 'lib/y_petri/simulation/marking_clamps/access.rb', line 10

def Marking_clamps array
  Clamped_places( array ).map { |place| marking_clamps.fetch( place ) }
end

#set_marking_clamp(place, to: (fail ArgumentError)) ⇒ Object

Sets the marking clamp of a place (frontend of InitialMarking#set).



35
36
37
# File 'lib/y_petri/simulation/marking_clamps/access.rb', line 35

def set_marking_clamp( place, to: (fail ArgumentError) )
  marking_clamps.set( place, to: to )
end