Sha256: 9a1e01b6e8e121b479751f5e23ad24cdadd3bb05c1ddc6b817b7cae2bd7ab8e5

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

class YPetri::Net::State
  class Features
    # A collection of values for a given set of state features.
    # 
    class Record < Array
      class << self
        delegate :State,
                 :net,
                 to: "Features()"

        # Construcs a new Record object from a given collection of values.
        # 
        def load values
          new( values.dup )
        end
      end

      delegate :Features,
               :State,
               :net,
               :features,
               to: "self.class"

      # Outputs the record as a plain array.
      # 
      def dump precision: nil
        features.map { |f| fetch( f ).round( precision ) }
      end

      # Returns an identified feature, or fails.
      # 
      def fetch feature
        super begin
                Integer( feature )
              rescue TypeError
                features.index State().feature( feature )
              end
      end

      # Returns the state instance implied by the receiver record, and a set of
      # complementary marking clamps supplied as the argument.
      # 
      def state marking_clamps: {}
        State.new self, marking_clamps: marking_clamps
      end

      delegate :reconstruct, to: :state
    end # class Record
  end # class Features
end # YPetri::Net::State

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
y_petri-2.1.3 lib/y_petri/net/state/features/record.rb