Class: OrigenTesters::Charz::Routine
- Inherits:
-
Object
- Object
- OrigenTesters::Charz::Routine
- 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
Instance Attribute Summary collapse
-
#id ⇒ Symbol
Charz routine symbol, used as a key in OrigenTesters::Charz#charz_routines.
-
#name ⇒ Symbol
The value used (if the user decides) to generate the name of the created charz test.
Instance Method Summary collapse
-
#initialize(id, options = {}, &block) ⇒ Routine
constructor
A new instance of Routine.
- #method_missing(m, *args, &block) ⇒ Object
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, = {}, &block) @id = id @id = @id.symbolize unless id.is_a? Symbol .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
#id ⇒ Symbol
Returns 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 |
#name ⇒ Symbol
Returns 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 |