Sha256: 77a52513cc72e1b5e077605eee0873e1864abab490fbe6652c7dda06a3de9fc8

Contents?: true

Size: 1.82 KB

Versions: 24

Compression:

Stored size: 1.82 KB

Contents

module Inch
  module Language
    module Ruby
      module CodeObject
        # Proxy class for methods
        class MethodObject < Base
          def constructor?
            self[:constructor?]
          end

          def bang_name?
            self[:bang_name?]
          end

          def getter?
            self[:getter?]
          end

          def has_parameters?
            !parameters.empty?
          end

          MANY_PARAMETERS_THRESHOLD = 3
          def has_many_parameters?
            parameters.size > MANY_PARAMETERS_THRESHOLD
          end

          MANY_LINES_THRESHOLD = 20
          def has_many_lines?
            # for now, this includes the 'def' line and comments
            if source
              size = source.lines.count
              size > MANY_LINES_THRESHOLD
            else
              false
            end
          end

          def parameter(name)
            parameters.find { |p| p.name == name.to_s }
          end

          def parameters
            @parameters ||= self[:parameters].map do |param_attr|
              MethodParameterObject.new(param_attr)
            end
          end

          def overridden?
            self[:overridden?]
          end

          def overridden_method
            @overridden_method ||=
              object_lookup.find(self[:overridden_method_fullname])
          end

          def return_mentioned?
            self[:return_mentioned?]
          end

          def return_described?
            self[:return_described?]
          end

          def return_typed?
            self[:return_typed?]
          end

          def setter?
            self[:setter?]
          end

          def source
            self[:source?]
          end

          def questioning_name?
            self[:questioning_name?]
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
inch-0.5.0.rc7 lib/inch/language/ruby/code_object/method_object.rb
inch-0.5.0.rc6 lib/inch/language/ruby/code_object/method_object.rb
inch-0.5.0.rc5 lib/inch/language/ruby/code_object/method_object.rb
inch-0.5.0.rc4 lib/inch/language/ruby/code_object/method_object.rb