Sha256: 72b7f300c55d28022967be35a91981c34443576b39683c6bd958e63a936552ba

Contents?: true

Size: 1.5 KB

Versions: 18

Compression:

Stored size: 1.5 KB

Contents

module Inch
  module CodeObject
    module Proxy
      # Proxy class for method parameters
      class MethodParameterObject
        def initialize(attributes)
          @attributes = attributes
        end

        def [](key)
          @attributes[key]
        end

        BAD_NAME_EXCEPTIONS = %w(id)
        BAD_NAME_THRESHOLD = 3

        # @return [Boolean] +true+ if the name of the parameter is uncommunicative
        def bad_name?
          return false if BAD_NAME_EXCEPTIONS.include?(name)
          name.size < BAD_NAME_THRESHOLD || name =~ /[0-9]$/
        end

        # @return [Boolean] +true+ if the parameter is a block
        def block?
          self[:block?]
        end

        # @return [Boolean] +true+ if an additional description given?
        def described?
          self[:described?]
        end

        # @return [Boolean] +true+ if the parameter is mentioned in the docs
        def mentioned?
          self[:mentioned?]
        end

        def name
          self[:name]
        end
        alias fullname name

        # @return [Boolean] +true+ if the parameter is a splat argument
        def splat?
          self[:splat?]
        end

        # @return [Boolean] +true+ if the type of the parameter is defined
        def typed?
          self[:typed?]
        end

        # @return [Boolean] +true+ if the parameter is mentioned in the docs, but not present in the method's signature
        def wrongly_mentioned?
          self[:wrongly_mentioned?]
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
inch-0.5.0.rc3 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.5.0.rc2 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.5.0.rc1 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.6 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.5 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.4 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.4.rc4 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.4.rc3 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.4.rc2 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.4.rc1 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.3 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.3.rc2 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.3.rc1 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.2 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.1 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.0 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.0.rc3 lib/inch/code_object/proxy/method_parameter_object.rb
inch-0.4.0.rc2 lib/inch/code_object/proxy/method_parameter_object.rb