Module: JavaClass::SimpleNameLogic
- Included in:
- JavaQualifiedName
- Defined in:
- lib/javaclass/java_name.rb
Overview
Mixin with logic to work with Java simple names. The “mixer” needs to declare a String field @simple_name.
- Author
-
Peter Kofler
Instance Method Summary collapse
-
#simple_name ⇒ Object
Return the simple name of this class or package.
-
#split_simple_name(pos) ⇒ Object
Split the simple name at the camel case boundary pos and return two parts.
Instance Method Details
#simple_name ⇒ Object
Return the simple name of this class or package. This returns just the plain String.
52 53 54 |
# File 'lib/javaclass/java_name.rb', line 52 def simple_name @simple_name end |
#split_simple_name(pos) ⇒ Object
Split the simple name at the camel case boundary pos and return two parts. pos may be < 0 for counting backwards.
57 58 59 60 61 62 63 |
# 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 |