class RPetri::PlaceWithLimit

Public Class Methods

new(name = nil, options = {}, &block) click to toggle source
Calls superclass method
# File lib/rpetri/extentions/place_with_limit.rb, line 3
def initialize(name = nil, options = {}, &block)
  @limit = options[:limit]
  super
end

Public Instance Methods

tokens_to_take(tokens, tokens_given) click to toggle source
# File lib/rpetri/extentions/place_with_limit.rb, line 8
def tokens_to_take(tokens, tokens_given)
  left_to_limit = @limit - tokens
  tokens_given > left_to_limit ? left_to_limit : tokens_given
end