Class: Origen::Tests::Test

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Test.



6
7
8
9
10
11
12
13
14
# File 'lib/origen/tests/test.rb', line 6

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



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/origen/tests/test.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

#conditionsObject

Returns the value of attribute conditions.



4
5
6
# File 'lib/origen/tests/test.rb', line 4

def conditions
  @conditions
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/origen/tests/test.rb', line 4

def description
  @description
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/origen/tests/test.rb', line 4

def id
  @id
end

#ownerObject

Returns the value of attribute owner.



4
5
6
# File 'lib/origen/tests/test.rb', line 4

def owner
  @owner
end

#platformsObject

Returns the value of attribute platforms.



4
5
6
# File 'lib/origen/tests/test.rb', line 4

def platforms
  @platforms
end

Instance Method Details

#nameObject



16
17
18
# File 'lib/origen/tests/test.rb', line 16

def name
  @id
end