Class: Origen::Tests::Test

Inherits:
Object show all
Includes:
Limits
Defined in:
lib/origen/tests/test.rb

Constant Summary

Constants included from Limits

Limits::TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Limits

#add_limits, #limits

Constructor Details

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

Returns a new instance of Test.



9
10
11
12
13
14
15
16
17
# File 'lib/origen/tests/test.rb', line 9

def initialize(id, options = {}, &block)
  @id = id
  @description = ''
  @conditions, @platforms = [], []
  @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?
  fail unless attrs_ok?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/origen/tests/test.rb', line 23

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

#conditionsObject

Returns the value of attribute conditions.



7
8
9
# File 'lib/origen/tests/test.rb', line 7

def conditions
  @conditions
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/origen/tests/test.rb', line 7

def description
  @description
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/origen/tests/test.rb', line 7

def id
  @id
end

#ownerObject

Returns the value of attribute owner.



7
8
9
# File 'lib/origen/tests/test.rb', line 7

def owner
  @owner
end

#platformsObject

Returns the value of attribute platforms.



7
8
9
# File 'lib/origen/tests/test.rb', line 7

def platforms
  @platforms
end

Instance Method Details

#nameObject



19
20
21
# File 'lib/origen/tests/test.rb', line 19

def name
  @id
end