Class: OrigenTesters::Charz::Routine

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_testers/charz/routine.rb

Overview

A Generic charz routine Used to store characterization test specific meta data, values of which are used by the user to determine test parameter values

Direct Known Subclasses

SearchRoutine, ShmooRoutine

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}, &block) ⇒ Routine

Returns a new instance of Routine.



12
13
14
15
16
17
18
# File 'lib/origen_testers/charz/routine.rb', line 12

def initialize(id, options = {}, &block)
  @id = id
  @id = @id.symbolize unless id.is_a? Symbol
  options.each { |k, v| instance_variable_set("@#{k}", v) }
  (block.arity < 1 ? (instance_eval(&block)) : block.call(self)) if block_given?
  @name ||= @id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/origen_testers/charz/routine.rb', line 20

def method_missing(m, *args, &block)
  ivar = "@#{m.to_s.gsub('=', '')}"
  ivar_sym = ":#{ivar}"
  if m.to_s =~ /=$/
    define_singleton_method(m) do |val|
      instance_variable_set(ivar, val)
    end
  elsif instance_variables.include? ivar_sym
    instance_variable_get(ivar)
  else
    define_singleton_method(m) do
      instance_variable_get(ivar)
    end
  end
  send(m, *args, &block)
end

Instance Attribute Details

#idSymbol

Returns charz routine symbol, used as a key in OrigenTesters::Charz#charz_routines.

Returns:

  • (Symbol)

    charz routine symbol, used as a key in OrigenTesters::Charz#charz_routines



10
11
12
# File 'lib/origen_testers/charz/routine.rb', line 10

def id
  @id
end

#nameSymbol

Returns the value used (if the user decides) to generate the name of the created charz test. defaults to the value of @id.

Returns:

  • (Symbol)

    the value used (if the user decides) to generate the name of the created charz test. defaults to the value of @id



10
# File 'lib/origen_testers/charz/routine.rb', line 10

attr_accessor :id, :name