Class: Squash::Java::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/squash/java/namespace.rb

Overview

Represents a Java instance method. Polymorphism is handled by using separate Method instances with different #arguments values.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, name, return_type, *arguments) ⇒ Method

Returns a new instance of Method.



494
495
496
497
498
499
500
# File 'lib/squash/java/namespace.rb', line 494

def initialize(klass, name, return_type, *arguments)
  @klass       = klass
  @name        = name
  @return_type = return_type
  @arguments   = arguments
  klass.java_methods << self
end

Instance Attribute Details

#argumentsArray<Squash::Java::Argument> (readonly)

Returns The method arguments.

Returns:



477
478
479
# File 'lib/squash/java/namespace.rb', line 477

def arguments
  @arguments
end

#klassSquash::Java::Class (readonly)

Returns The class owning this method.

Returns:



468
469
470
# File 'lib/squash/java/namespace.rb', line 468

def klass
  @klass
end

#nameString (readonly)

Returns The method name.

Returns:

  • (String)

    The method name.



474
475
476
# File 'lib/squash/java/namespace.rb', line 474

def name
  @name
end

#obfuscationString?

Returns The obfuscated method name.

Returns:

  • (String, nil)

    The obfuscated method name.



480
481
482
# File 'lib/squash/java/namespace.rb', line 480

def obfuscation
  @obfuscation
end

#return_typeSquash::Java::Argument (readonly)

Returns The type of object returned.

Returns:



471
472
473
# File 'lib/squash/java/namespace.rb', line 471

def return_type
  @return_type
end

Instance Method Details

#add_argument(type) ⇒ Object



503
504
505
506
# File 'lib/squash/java/namespace.rb', line 503

def add_argument(type)
  @arguments << type
  @arguments.size - 1
end

#full_nameString

Returns The full method name, along with return value and arguments as full type names.

Returns:

  • (String)

    The full method name, along with return value and arguments as full type names.



511
512
513
514
# File 'lib/squash/java/namespace.rb', line 511

def full_name
  args = arguments.map { |type| type.to_s }.join(', ')
  "#{return_type.to_s} #{name}(#{args})"
end

#inspectObject



517
# File 'lib/squash/java/namespace.rb', line 517

def inspect() "#<#{self.class.to_s} #{full_name}>" end