Exception: RubyLess::NoMethodError
- Defined in:
- lib/ruby_less/no_method_error.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(receiver, klass, signature) ⇒ NoMethodError
constructor
A new instance of NoMethodError.
- #ivar? ⇒ Boolean
- #message ⇒ Object
- #method_with_arguments ⇒ Object
- #receiver_with_class ⇒ Object
Constructor Details
#initialize(receiver, klass, signature) ⇒ NoMethodError
Returns a new instance of NoMethodError.
5 6 7 8 9 |
# File 'lib/ruby_less/no_method_error.rb', line 5 def initialize(receiver, klass, signature) @receiver = receiver @klass = klass @signature = signature end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/ruby_less/no_method_error.rb', line 3 def klass @klass end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
3 4 5 |
# File 'lib/ruby_less/no_method_error.rb', line 3 def receiver @receiver end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
3 4 5 |
# File 'lib/ruby_less/no_method_error.rb', line 3 def signature @signature end |
Instance Method Details
#error_message ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/ruby_less/no_method_error.rb', line 15 def if ivar? "unknown instance variable" else "unknown method" end end |
#ivar? ⇒ Boolean
43 44 45 |
# File 'lib/ruby_less/no_method_error.rb', line 43 def ivar? @signature.first =~ /\A@/ end |
#message ⇒ Object
11 12 13 |
# File 'lib/ruby_less/no_method_error.rb', line 11 def "#{} '#{method_with_arguments}' for #{receiver_with_class}." end |
#method_with_arguments ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_less/no_method_error.rb', line 28 def method_with_arguments method = @signature.first signature = @signature[1..-1] return method if ivar? if signature.size == 0 arguments = '' else arguments = signature.map{|s| s.kind_of?(Class) ? s.to_s : s.inspect}.join(', ') if signature.size == 1 && (signature.first.kind_of?(Array) || signature.first.kind_of?(Hash)) arguments = arguments[1..-2] end end "#{method}(#{arguments})" end |
#receiver_with_class ⇒ Object
23 24 25 26 |
# File 'lib/ruby_less/no_method_error.rb', line 23 def receiver_with_class klass = @klass.kind_of?(Class) ? @klass : @klass.class @receiver ? "'#{@receiver}' of type #{@klass}" : klass end |