Sha256: d1065620d6a5955614d7f105b1fcfe1112dee6c63d1b90c6412179972bc97016

Contents?: true

Size: 1.61 KB

Versions: 17

Compression:

Stored size: 1.61 KB

Contents

module OrigenTesters
  module SmartestBasedTester
    class Base
      class TestMethods
        class Limits
          attr_reader :test_method
          attr_accessor :lo_limit, :hi_limit
          attr_accessor :unit
          alias_method :lo, :lo_limit
          alias_method :lo=, :lo_limit=
          alias_method :hi, :hi_limit
          alias_method :hi=, :hi_limit=

          def initialize(test_method)
            @test_method = test_method
          end

          def unit=(val)
            case val.to_s.downcase
            when 'v', 'volts'
              @unit = 'V'
            when 'a', 'amps'
              @unit = 'A'
            else
              fail "Limit unit of #{val} not implemented yet!"
            end
          end

          def to_s
            if !lo_limit && !hi_limit
              "\"#{test_name}\"" + ' = "":"NA":"":"NA":"":"":""'
            elsif !lo_limit
              "\"#{test_name}\"" + " = \"\":\"NA\":\"#{hi_limit}\":\"LE\":\"#{unit}\":\"\":\"0\""
            elsif !hi_limit
              "\"#{test_name}\"" + " = \"#{lo_limit}\":\"GE\":\"\":\"NA\":\"#{unit}\":\"\":\"0\""
            else
              "\"#{test_name}\"" + " = \"#{lo_limit}\":\"GE\":\"#{hi_limit}\":\"LE\":\"#{unit}\":\"\":\"0\""
            end
          end

          def set_lo_limit(val)
            self.lo_limit = val
          end

          def set_hi_limit(val)
            self.hi_limit = val
          end

          private

          def test_name
            name = test_method.test_name if test_method.respond_to?(:test_name)
            name || 'Functional'
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
origen_testers-0.8.11 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.8 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.7 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.6 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.5 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.4 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.3 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.2 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.1 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.0 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.8.0.pre1 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.7.13 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.7.12 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.7.11 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.7.10 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.7.9 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb
origen_testers-0.7.8 lib/origen_testers/smartest_based_tester/base/test_methods/limits.rb