Class: UnifiedMatchers::MatcherResult
- Defined in:
- lib/unified_matchers/matcher_result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#my ⇒ Object
readonly
Returns the value of attribute my.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #compute_messages(message) ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(name, ref, my, message_ref, message_my, default_message, status, data = nil, message = nil) ⇒ MatcherResult
constructor
A new instance of MatcherResult.
- #message ⇒ Object
- #method_missing(*a, &b) ⇒ Object
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, ref, my, message_ref, message_my, default_message, status, data = nil, message = nil) ⇒ MatcherResult
Returns a new instance of MatcherResult.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/unified_matchers/matcher_result.rb', line 12 def initialize name, ref, my, , , , status, data=nil, =nil if status == true or status == false @name = name @status = status @data = data @ref = ref @my = my @message_ref = @message_my = if .nil? = end @message_template = else raise ArgumentError, "The status must be true or false, not #{status}." end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a, &b) ⇒ Object
65 66 67 |
# File 'lib/unified_matchers/matcher_result.rb', line 65 def method_missing *a, &b @data.send(*a, &b) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/unified_matchers/matcher_result.rb', line 10 def data @data end |
#my ⇒ Object (readonly)
Returns the value of attribute my.
10 11 12 |
# File 'lib/unified_matchers/matcher_result.rb', line 10 def my @my end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/unified_matchers/matcher_result.rb', line 10 def name @name end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
10 11 12 |
# File 'lib/unified_matchers/matcher_result.rb', line 10 def ref @ref end |
Instance Method Details
#compute_messages(message) ⇒ Object
52 53 54 55 |
# File 'lib/unified_matchers/matcher_result.rb', line 52 def x = .shift.inspect_for_unified_matchers .inject(x) { |accu, y| y.gsub('%x', accu) } end |
#failure? ⇒ Boolean
35 36 37 |
# File 'lib/unified_matchers/matcher_result.rb', line 35 def failure? ! @status end |
#message ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/unified_matchers/matcher_result.rb', line 39 def if defined? @message @message else str = '' str << 'not ' if failure? str << @message_template str.gsub!('%ref', (@message_ref)) str.gsub!('%my', (@message_my)) @message = str end end |
#success? ⇒ Boolean
31 32 33 |
# File 'lib/unified_matchers/matcher_result.rb', line 31 def success? @status end |
#to_s ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/unified_matchers/matcher_result.rb', line 57 def to_s if @name.nil? else "#@name: #{}" end end |