Sha256: 107992772dcc3559c128c4dbfdddb4d0fe87137e451df48adc306ce12b3df5f3

Contents?: true

Size: 1.11 KB

Versions: 111

Compression:

Stored size: 1.11 KB

Contents

module Origen
  module Pins
    class PowerPin < Pin
      attr_accessor :current_limit

      def initialize(id, owner, options = {}) # :nodoc:
        v = options[:voltage] || options[:voltages]
        self.voltage = v if v
        self.current_limit = options[:current_limit] if options[:current_limit]
        super
      end

      # Set the operating voltage for the pin, can be a single value or an array
      def voltage=(val)
        @voltages = [val].flatten.uniq
      end

      # Like voltages but if there is only one voltage known then it will be returned
      # directly instead of being wrapped in an array.
      # If no voltages are known this returns nil whereas voltages will return an
      # empty array.
      # For more than one voltages present this behaves like an alias of voltages.
      def voltage
        if voltages.size > 0
          if voltages.size > 1
            voltages
          else
            voltages.first
          end
        end
      end

      # Returns an array of known operating voltages for the given pin
      def voltages
        @voltages ||= []
      end
    end
  end
end

Version data entries

111 entries across 111 versions & 1 rubygems

Version Path
origen-0.54.3 lib/origen/pins/power_pin.rb
origen-0.54.2 lib/origen/pins/power_pin.rb
origen-0.54.1 lib/origen/pins/power_pin.rb
origen-0.54.0 lib/origen/pins/power_pin.rb
origen-0.53.1 lib/origen/pins/power_pin.rb
origen-0.53.0 lib/origen/pins/power_pin.rb
origen-0.52.4 lib/origen/pins/power_pin.rb
origen-0.52.3 lib/origen/pins/power_pin.rb
origen-0.52.2 lib/origen/pins/power_pin.rb
origen-0.52.1 lib/origen/pins/power_pin.rb
origen-0.52.0 lib/origen/pins/power_pin.rb
origen-0.51.3 lib/origen/pins/power_pin.rb
origen-0.51.2 lib/origen/pins/power_pin.rb
origen-0.51.1 lib/origen/pins/power_pin.rb
origen-0.51.0 lib/origen/pins/power_pin.rb
origen-0.50.0 lib/origen/pins/power_pin.rb
origen-0.44.0 lib/origen/pins/power_pin.rb
origen-0.43.0 lib/origen/pins/power_pin.rb
origen-0.42.2 lib/origen/pins/power_pin.rb
origen-0.42.1 lib/origen/pins/power_pin.rb