Exception: MustBe::Note

Inherits:
StandardError
  • Object
show all
Defined in:
lib/must_be/core.rb

Overview

Note ###

Direct Known Subclasses

ContainerNote

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver, assertion = nil, args = nil, block = nil, additional_message = nil) ⇒ Note

Returns a new instance of Note.



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/must_be/core.rb', line 151

def initialize(receiver, assertion = nil, args = nil, block = nil,
    additional_message = nil)
  if assertion
    @receiver = receiver
    @assertion = assertion
    @args = args
    @block = block
    @additional_message = additional_message
  else
    super(receiver)
  end
end

Instance Attribute Details

#additional_messageObject

Returns the value of attribute additional_message.



148
149
150
# File 'lib/must_be/core.rb', line 148

def additional_message
  @additional_message
end

#argsObject

Returns the value of attribute args.



148
149
150
# File 'lib/must_be/core.rb', line 148

def args
  @args
end

#assertionObject

Returns the value of attribute assertion.



148
149
150
# File 'lib/must_be/core.rb', line 148

def assertion
  @assertion
end

#blockObject

Returns the value of attribute block.



148
149
150
# File 'lib/must_be/core.rb', line 148

def block
  @block
end

#prefixObject

Returns the value of attribute prefix.



148
149
150
# File 'lib/must_be/core.rb', line 148

def prefix
  @prefix
end

#receiverObject

Returns the value of attribute receiver.



148
149
150
# File 'lib/must_be/core.rb', line 148

def receiver
  @receiver
end

Instance Method Details

#backtraceObject



175
176
177
178
179
# File 'lib/must_be/core.rb', line 175

def backtrace
  complete_backtrace and complete_backtrace.drop_while do |line|
    line =~ %r{lib/must_be.*\.rb:}
  end
end

#complete_backtraceObject



173
# File 'lib/must_be/core.rb', line 173

alias complete_backtrace backtrace

#to_sObject



164
165
166
167
168
169
170
171
# File 'lib/must_be/core.rb', line 164

def to_s
  if assertion
    "#{prefix}#{MustBe.short_inspect(receiver)}."\
      "#{assertion}#{format_args_and_block}#{additional_message}"
  else
    super
  end
end