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.
547 548 549 550 |
# File 'lib/test/unit/assertions.rb', line 547 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.
545 546 547 |
# File 'lib/test/unit/assertions.rb', line 545 def count @count end |
Class Method Details
.create(string) ⇒ Object
540 541 542 543 |
# File 'lib/test/unit/assertions.rb', line 540 def self.create(string) parts = (string ? string.scan(/(?=[^\\])\?|(?:\\\?|[^\?])+/m) : []) self.new(parts) end |
Instance Method Details
#result(parameters) ⇒ Object
552 553 554 555 556 |
# File 'lib/test/unit/assertions.rb', line 552 def result(parameters) raise "The number of parameters does not match the number of substitutions." if(parameters.size != count) params = parameters.dup @parts.collect{|e| e == '?' ? params.shift : e.gsub(/\\\?/m, '?')}.join('') end |