Sha256: 9beea15b00aa9c2c9f41d8ab7cbb6e0f234af43511e2b163c78df9df0a634eca
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module SPNet class Block include Hashmake::HashMakeable attr_reader :name, :in_ports, :out_ports DO_NOTHING = ->(){} HASHED_ARG_SPECS = [ Hashmake::ArgSpec.new(:reqd => false, :key => :name, :type => String, :default => "UNNAMED"), Hashmake::ArgSpec.new(:reqd => false, :key => :algorithm, :type => Proc, :default => DO_NOTHING), Hashmake::ArgSpec.new(:reqd => false, :key => :in_ports, :type => InPort, :array => true, :default => ->(){ Array.new } ), Hashmake::ArgSpec.new(:reqd => false, :key => :out_ports, :type => OutPort, :array => true, :default => ->(){ Array.new }), ] def initialize args = {} hash_make Block::HASHED_ARG_SPECS, args end def find_ports name, ignore_case = true matches = (@in_ports + @out_ports).select do |port| if ignore_case port.name.casecmp(name) == 0 else port.name == name end end return matches end def find_first_port name, ignore_case = true return find_ports(name, ignore_case).first end def step count @algorithm.call count end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spnet-0.1.3 | lib/spnet/block.rb |