Class: Test::Unit::Assertions::AssertionMessage::Template
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/test/unit/assertions.rb |
Class Method Summary
- .create(string)
- .new(parts) ⇒ Template constructor
Instance Attribute Summary
- #count readonly
Instance Method Summary
- #result(parameters)
-
#encoding_safe_concat(buffer, parameter)
private
See additional method definition at line 2053.
Constructor Details
.new(parts) ⇒ Template
# File 'lib/test/unit/assertions.rb', line 2032
def initialize(parts) @parts = parts @count = parts.find_all{|e| e == '?'}.size end
Class Method Details
.create(string)
[ GitHub ]# File 'lib/test/unit/assertions.rb', line 2025
def self.create(string) parts = (string ? string.scan(/(?=[^\\])\?|(?:\\\?|[^\?])+/m) : []) self.new(parts) end
Instance Attribute Details
#count (readonly)
[ GitHub ]# File 'lib/test/unit/assertions.rb', line 2030
attr_reader :count
Instance Method Details
#encoding_safe_concat(buffer, parameter) (private)
See additional method definition at line 2053.
# File 'lib/test/unit/assertions.rb', line 2061
def encoding_safe_concat(buffer, parameter) if Encoding.compatible?(buffer, parameter) buffer << parameter else buffer << parameter.dup.force_encoding(buffer.encoding) end end
#result(parameters)
[ GitHub ]# File 'lib/test/unit/assertions.rb', line 2037
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 == '?' encoding_safe_concat(, params.shift) else << part.gsub(/\\\?/m, '?') end end end