Sha256: 13838f6dac9228b696a7c0ae6cb48eb2fc48805a4248735d6915138ad1a2190c
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module RubyLess class NoMethodError < RubyLess::Error attr_reader :receiver, :klass, :signature def initialize(receiver, klass, signature) @receiver = receiver @klass = klass @signature = signature end def message "#{receiver_with_class}: #{error_message} '#{method_with_arguments}'." end def error_message if ivar? "unknown instance variable" else "unknown method" end end def receiver_with_class @receiver ? "#{@receiver} (#{@klass})" : "(#{@klass.class})" end 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 def ivar? @signature.first =~ /\A@/ end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyless-0.4.0 | lib/ruby_less/no_method_error.rb |