class ApiDiff::Function

Attributes

name[R]
return_type[R]
signature[R]

Public Class Methods

new(name:, signature:, return_type:, static:, constructor:) click to toggle source
# File lib/api_diff/function.rb, line 5
def initialize(name:, signature:, return_type:, static:, constructor:)
  @name = name
  @signature = signature
  @return_type = return_type
  @static = static
  @constructor = constructor
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/api_diff/function.rb, line 41
def <=>(other)
  # static at the bottom
  return 1 if is_static? and not other.is_static?
  return -1 if not is_static? and other.is_static?

  # constructors first
  return -1 if is_constructor? and not other.is_constructor?
  return 1 if not is_constructor? and other.is_constructor?

  if is_constructor?
    # sort constructors by length
    [full_signature.size, full_signature] <=> [other.full_signature.size, other.full_signature]
  else
    [name, full_signature] <=> [other.name, other.full_signature]
  end
end
eql?(other) click to toggle source
# File lib/api_diff/function.rb, line 37
def eql?(other)
  full_signature == other.full_signature
end
full_signature() click to toggle source
# File lib/api_diff/function.rb, line 25
def full_signature
  if return_type.nil?
    signature
  else
    "#{signature} -> #{return_type}"
  end
end
hash() click to toggle source
# File lib/api_diff/function.rb, line 33
def hash
  full_signature.hash
end
is_constructor?() click to toggle source
# File lib/api_diff/function.rb, line 13
def is_constructor?
  @constructor
end
is_static?() click to toggle source
# File lib/api_diff/function.rb, line 17
def is_static?
  @static
end
to_s() click to toggle source
# File lib/api_diff/function.rb, line 21
def to_s
  full_signature
end