Sha256: 54c5ac39ed9d67d1446263c324e7fb0f52998b6c8aeb20826199ef554209cd1c

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

module OrigenTesters
  module IGXLBasedTester
    class Base
      class PatsubrPattern
        ALIASES = {
          pattern: :file_name
        }

        def self.define
          # Generate accessors for all attributes and their aliases
          self::PATSUBR_ATTRS.each do |attr|
            writer = "#{attr}=".to_sym
            reader = attr.to_sym
            attr_reader attr.to_sym unless method_defined? reader
            attr_writer attr.to_sym unless method_defined? writer
          end

          ALIASES.each do |_alias, val|
            writer = "#{_alias}=".to_sym
            reader = _alias.to_sym
            unless method_defined? writer
              define_method("#{_alias}=") do |v|
                send("#{val}=", v)
              end
            end
            unless method_defined? reader
              define_method("#{_alias}") do
                send(val)
              end
            end
          end
        end

        def initialize(patsubr, attrs = {})
          # Set the defaults
          self.class::PATSUBR_DEFAULTS.each do |k, v|
            send("#{k}=", v)
          end
          # Then the values that have been supplied
          self.pattern_subr = patsubr
          attrs.each do |k, v|
            send("#{k}=", v)
          end
        end

        def to_s
          l = "\t"
          self.class::PATSUBR_ATTRS.each do |attr|
            l += "#{send(attr)}\t"
          end
          "#{l}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
origen_testers-0.13.2 lib/origen_testers/igxl_based_tester/base/patsubr_pattern.rb
origen_testers-0.10.0 lib/origen_testers/igxl_based_tester/base/patsubr_pattern.rb