Class: Origen::Tester::Doc::Generator::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/tester/doc/generator/test.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Test) initialize(name, attrs = {})

Returns a new instance of Test



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/origen/tester/doc/generator/test.rb', line 8

def initialize(name, attrs = {})
  attrs = {}.merge(attrs)  # Important to keep this to clone the original options
  # so that the caller's copy if not affected by stripping
  # out the flow/relation options
  @attributes = {}
  @append_version = true
  self.name = name
  Origen.interface.extract_relation_options!(attrs)
  Origen.interface.extract_flow_control_options!(attrs)
  attrs.each do |attribute, val|
    @attributes[attribute] = val
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &_block)



37
38
39
40
41
42
43
44
# File 'lib/origen/tester/doc/generator/test.rb', line 37

def method_missing(method, *args, &_block)
  method = method.to_s
  if method.gsub!('=', '')
    @attributes[method] = args.first
  else
    @attributes[method]
  end
end

Instance Attribute Details

- (Object) append_version

Returns the value of attribute append_version



6
7
8
# File 'lib/origen/tester/doc/generator/test.rb', line 6

def append_version
  @append_version
end

- (Object) attributes

Returns the value of attribute attributes



6
7
8
# File 'lib/origen/tester/doc/generator/test.rb', line 6

def attributes
  @attributes
end

- (Object) index

Returns the value of attribute index



6
7
8
# File 'lib/origen/tester/doc/generator/test.rb', line 6

def index
  @index
end

- (Object) name

Returns the value of attribute name



6
7
8
# File 'lib/origen/tester/doc/generator/test.rb', line 6

def name
  @name
end

- (Object) version

Returns the value of attribute version



6
7
8
# File 'lib/origen/tester/doc/generator/test.rb', line 6

def version
  @version
end

Instance Method Details

- (Object) ==(other_test)



46
47
48
49
50
51
# File 'lib/origen/tester/doc/generator/test.rb', line 46

def ==(other_test)
  self.class == other_test.class &&
    unversioned_name.to_s == other_test.unversioned_name.to_s &&
    attributes.size == other_test.attributes.size &&
    attributes.all? { |name, val| other_test.attributes[name] == val }
end

- (Object) attributes_to_yaml(_options = {})



28
29
30
31
32
33
34
35
# File 'lib/origen/tester/doc/generator/test.rb', line 28

def attributes_to_yaml(_options = {})
  a = {}
  @attributes.each do |name, val|
    a[name.to_s] = val if val
  end
  a['name'] = name
  a
end

- (Object) to_yaml(options = {})



22
23
24
25
26
# File 'lib/origen/tester/doc/generator/test.rb', line 22

def to_yaml(options = {})
  {
    'attributes' => attributes_to_yaml(options)
  }
end

- (Object) unversioned_name



61
62
63
# File 'lib/origen/tester/doc/generator/test.rb', line 61

def unversioned_name
  @name.to_s
end