Class: Origen::Tests::Test
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#platforms ⇒ Object
Returns the value of attribute platforms.
Instance Method Summary collapse
-
#initialize(id, options = {}, &block) ⇒ Test
constructor
A new instance of Test.
- #method_missing(m, *args, &block) ⇒ Object
- #name ⇒ Object
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, = {}, &block) @id = id @description = '' @conditions, @platforms = [], [] @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? 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
#conditions ⇒ Object
Returns the value of attribute conditions.
4 5 6 |
# File 'lib/origen/tests/test.rb', line 4 def conditions @conditions end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/origen/tests/test.rb', line 4 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/origen/tests/test.rb', line 4 def id @id end |
#owner ⇒ Object
Returns the value of attribute owner.
4 5 6 |
# File 'lib/origen/tests/test.rb', line 4 def owner @owner end |
#platforms ⇒ Object
Returns the value of attribute platforms.
4 5 6 |
# File 'lib/origen/tests/test.rb', line 4 def platforms @platforms end |
Instance Method Details
#name ⇒ Object
16 17 18 |
# File 'lib/origen/tests/test.rb', line 16 def name @id end |