Class: Test::Unit::Assertions::AssertionMessage::Template
- Inherits:
-
Object
- Object
- Test::Unit::Assertions::AssertionMessage::Template
- Defined in:
- lib/test/unit/assertions.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parts) ⇒ Template
constructor
A new instance of Template.
- #result(parameters) ⇒ Object
Constructor Details
#initialize(parts) ⇒ Template
Returns a new instance of Template.
2040 2041 2042 2043 |
# File 'lib/test/unit/assertions.rb', line 2040 def initialize(parts) @parts = parts @count = parts.find_all{|e| e == '?'}.size end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
2038 2039 2040 |
# File 'lib/test/unit/assertions.rb', line 2038 def count @count end |
Class Method Details
.create(string) ⇒ Object
2033 2034 2035 2036 |
# File 'lib/test/unit/assertions.rb', line 2033 def self.create(string) parts = (string ? string.scan(/(?=[^\\])\?|(?:\\\?|[^\?])+/m) : []) self.new(parts) end |
Instance Method Details
#result(parameters) ⇒ Object
2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 |
# File 'lib/test/unit/assertions.rb', line 2045 def result(parameters) raise "The number of parameters does not match the number of substitutions." if(parameters.size != count) params = parameters.dup = "" @parts.each do |part| if part == '?' param = params.shift if Object.const_defined?(:Encoding) += concatenatable(param, .encoding) else += param end else += part.gsub(/\\\?/m, '?') end end end |