module JavaClass::SimpleNameLogic

Mixin with logic to work with Java simple names. The “mixer” needs to declare a String field @simple_name.

Author

Peter Kofler

Public Instance Methods

simple_name() click to toggle source

Return the simple name of this class or package. This returns just the plain String.

# File lib/javaclass/java_name.rb, line 52
def simple_name
  @simple_name
end
split_simple_name(pos) click to toggle source

Split the simple name at the camel case boundary pos and return two parts. pos may be < 0 for counting backwards.

# File lib/javaclass/java_name.rb, line 57
def split_simple_name(pos)
  parts = @simple_name.scan(/([A-Z][^A-Z]+)/).flatten
  pos = parts.size + pos + 1 if pos < 0
  return ['', @simple_name] if pos <= 0
  return [@simple_name, ''] if pos >= parts.size
  [parts[0...pos].join, parts[pos..-1].join]
end