Class: JavaClass::ClassList::PackageEntry
- Inherits:
-
Object
- Object
- JavaClass::ClassList::PackageEntry
- Defined in:
- lib/javaclass/classlist/package_entry.rb
Overview
A package in the List.
- Author
-
Peter Kofler
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
ZenTest FULL to find method <=>.
-
#version ⇒ Object
readonly
Return the list of versions this package exists.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sorting in packages is:
java.lang
, otherjava.*
,javax.*
and then others. - #add_class(class_name, is_public, version) ⇒ Object
-
#classes ⇒ Object
Return the classes in this package.
-
#initialize(name, vers = 0) ⇒ PackageEntry
constructor
Create a new package with name name and first version vers which is the version of the first class in the package.
-
#size ⇒ Object
Return the number of classes in this package.
-
#to_package_shortcut_s(minversion, maxversion) ⇒ Object
Special version of
to_s
for package shortcut. - #to_s ⇒ Object
Constructor Details
#initialize(name, vers = 0) ⇒ PackageEntry
Create a new package with name name and first version vers which is the version of the first class in the package.
15 16 17 18 19 |
# File 'lib/javaclass/classlist/package_entry.rb', line 15 def initialize(name, vers=0) @name = name @version = [vers] @classes = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
ZenTest FULL to find method <=>
10 11 12 |
# File 'lib/javaclass/classlist/package_entry.rb', line 10 def name @name end |
#version ⇒ Object (readonly)
Return the list of versions this package exists. This is the sum of all versions of all classes in the package.
12 13 14 |
# File 'lib/javaclass/classlist/package_entry.rb', line 12 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
Sorting in packages is: java.lang
, other java.*
, javax.*
and then others.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/javaclass/classlist/package_entry.rb', line 33 def <=>(other) if @name =~ /^java\.lang$/ and other.name !~ /^java\.lang$/ -1 elsif @name !~ /^java\.lang$/ and other.name =~ /^java\.lang$/ 1 elsif @name =~ /^java\./ and other.name !~ /^java\./ -1 elsif @name !~ /^java\./ and other.name =~ /^java\./ 1 elsif @name =~ /^javax\./ and other.name !~ /^javax\./ -1 elsif @name !~ /^javax\./ and other.name =~ /^javax\./ 1 else @name <=> other.name end end |
#add_class(class_name, is_public, version) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/javaclass/classlist/package_entry.rb', line 21 def add_class(class_name, is_public, version) @version << version unless @version.include? version @version = @version.sort unless @classes.has_key?(class_name) @classes[class_name] = ClassEntry.new(self, class_name, is_public, version) else @classes[class_name].update(version, is_public) end end |
#classes ⇒ Object
Return the classes in this package.
52 53 54 |
# File 'lib/javaclass/classlist/package_entry.rb', line 52 def classes @classes.values.sort end |
#size ⇒ Object
Return the number of classes in this package.
57 58 59 |
# File 'lib/javaclass/classlist/package_entry.rb', line 57 def size @classes.size end |
#to_package_shortcut_s(minversion, maxversion) ⇒ Object
Special version of to_s
for package shortcut. A package needs minversion and maxversion to determine if the whole package was dropped.
67 68 69 70 |
# File 'lib/javaclass/classlist/package_entry.rb', line 67 def to_package_shortcut_s(minversion, maxversion) "#{@name}#{format_version(minversion, maxversion)} - \n" + classes.collect { |c| c.to_package_shortcut_s }.join end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/javaclass/classlist/package_entry.rb', line 61 def to_s @name end |