Class: JavaClass::ClassList::ClassEntry
- Inherits:
-
Object
- Object
- JavaClass::ClassList::ClassEntry
- Defined in:
- lib/javaclass/classlist/class_entry.rb
Overview
An entry in the list. A ClassEntry belongs to a PackageEntry and has a list ov versions it exists in.
- Author
-
Peter Kofler
Instance Attribute Summary collapse
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#name ⇒ Object
readonly
Return the short (simple) name of this class.
-
#version ⇒ Object
readonly
Return the list of versions this class exists.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sorts by simple
name
inside the package. -
#initialize(parent, full_name, is_public, vers) ⇒ ClassEntry
constructor
Create a new entry.
- #public? ⇒ Boolean
-
#to_full_qualified_s(minversion, maxversion) ⇒ Object
Return a string containing the full qualified name together with first and last version of this class.
-
#to_package_shortcut_s ⇒ Object
Return a string containing the simple name and the version, if it is different from the package version.
- #to_s ⇒ Object
-
#update(version, is_public = @is_public) ⇒ Object
Update the version this class also exists in.
Constructor Details
#initialize(parent, full_name, is_public, vers) ⇒ ClassEntry
Create a new entry. parent must provide a version
field to compare against. vers is the base version of this class.
18 19 20 21 22 23 24 |
# File 'lib/javaclass/classlist/class_entry.rb', line 18 def initialize(parent, full_name, is_public, vers) @parent = parent @full_name = full_name.to_javaname.to_classname @name = @full_name.simple_name @is_public = is_public @version = [vers] end |
Instance Attribute Details
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
12 13 14 |
# File 'lib/javaclass/classlist/class_entry.rb', line 12 def full_name @full_name end |
#name ⇒ Object (readonly)
Return the short (simple) name of this class.
11 12 13 |
# File 'lib/javaclass/classlist/class_entry.rb', line 11 def name @name end |
#version ⇒ Object (readonly)
Return the list of versions this class exists.
14 15 16 |
# File 'lib/javaclass/classlist/class_entry.rb', line 14 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
Sorts by simple name
inside the package.
51 52 53 |
# File 'lib/javaclass/classlist/class_entry.rb', line 51 def <=>(other) @name.casecmp other.name end |
#public? ⇒ Boolean
26 27 28 |
# File 'lib/javaclass/classlist/class_entry.rb', line 26 def public? @is_public end |
#to_full_qualified_s(minversion, maxversion) ⇒ Object
Return a string containing the full qualified name together with first and last version of this class. Ignore package versions, but obey minversion and maxversion . Print all versions, first to last, but skip first<=minversion
and last>=maxversion
.
62 63 64 |
# File 'lib/javaclass/classlist/class_entry.rb', line 62 def to_full_qualified_s(minversion, maxversion) format_version(@full_name, minversion, maxversion) end |
#to_package_shortcut_s ⇒ Object
Return a string containing the simple name and the version, if it is different from the package version.
67 68 69 70 |
# File 'lib/javaclass/classlist/class_entry.rb', line 67 def to_package_shortcut_s vp = @parent.version format_version(" #{@name}", vp.first, vp.last) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/javaclass/classlist/class_entry.rb', line 55 def to_s @full_name end |
#update(version, is_public = @is_public) ⇒ Object
Update the version this class also exists in.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/javaclass/classlist/class_entry.rb', line 31 def update(version, is_public=@is_public) raise "update class #{@name} is older than its last version: latest version=#{@version.last}, new version=#{version}" if version <= @version.last # check for holes in versions if version > @version.last+1 warn "#{@full_name} last in version #{@version.last}, not in #{@version.last+1}, but again in #{version}" end @version << version if !is_public && @is_public warn "#{@full_name} changed from public to package in version #{version}" @is_public = is_public @version = [version] # skip older versions elsif is_public && ! @is_public info "#{@full_name} changed from package to public in version #{version}" @is_public = is_public @version = [version] # skip older versions end end |