Class: MobyUtil::FixtureParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FixtureParameter

Returns a new instance of FixtureParameter.



28
29
30
31
32
33
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb', line 28

def initialize( *args )
	@parameters = []
	# accept array as multiple arguments, hash for one argument
	args = [ [ args.first ] ] if args.size == 1 && args.first.kind_of?( Hash )
	args.each{ | argument | add_parameter( argument.first )	} 
end

Instance Attribute Details

#parametersObject

Returns the value of attribute parameters.



26
27
28
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb', line 26

def parameters
  @parameters
end

Instance Method Details

#add_parameter(hash) ⇒ Object

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb', line 35

def add_parameter( hash )

	raise ArgumentError.new("Argument :value and :type must be defined. Actual hash: #{ hash.inspect }") unless hash.has_key?( :type ) and hash.has_key?( :value )

	@parameters.push( hash )

end

#list_parametersObject



50
51
52
53
54
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb', line 50

def list_parameters

	return @parameters.inspect

end

#remove_parameter(index_or_range) ⇒ Object



43
44
45
46
47
48
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb', line 43

def remove_parameter( index_or_range )
 
	# value can be range or index, or array of ranges or indexes
	@parameters.slice!( index_or_range )

end

#to_sObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/fixture_parameter.rb', line 56

def to_s

	Nokogiri::XML::Builder.new{

		fixture_parameters{

			parameters.each_index{ | index | 

				parameter( parameters[index].merge( :id => index) )

			}

		}

	}.to_xml

end