Class: Artifacts::Artifact
- Inherits:
-
YAML_Model
- Object
- YAML_Model
- Artifacts::Artifact
- Defined in:
- lib/artifacts/artifact.rb
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #closed? ⇒ Boolean
- #depended_on_by ⇒ Object
- #depends_on ⇒ Object
- #inspect ⇒ Object
- #open? ⇒ Boolean
- #open_depended_on_by ⇒ Object
- #open_depends_on ⇒ Object
- #priority ⇒ Object
- #to_s ⇒ Object
Class Method Details
.priority_width ⇒ Object
22 23 24 |
# File 'lib/artifacts/artifact.rb', line 22 def self.priority_width all.map{|n|n.priority.to_s}.sort{|a,b|a.length <=> b.length}.last.length end |
Instance Method Details
#<=>(other) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/artifacts/artifact.rb', line 34 def <=>( other ) offset = ( closed? ^ other.closed? ) ? ( closed? ? 1 : -1 ) : 0 offset = other.priority <=> self.priority if offset == 0 offset = other.open_depended_on_by.size <=> self.open_depended_on_by.size if offset == 0 offset = self.id <=> other.id if offset == 0 offset end |
#closed? ⇒ Boolean
30 31 32 |
# File 'lib/artifacts/artifact.rb', line 30 def closed? closed != nil end |
#depended_on_by ⇒ Object
54 55 56 |
# File 'lib/artifacts/artifact.rb', line 54 def depended_on_by depends_on_references.map{|n|n.depended_on_by} end |
#depends_on ⇒ Object
46 47 48 |
# File 'lib/artifacts/artifact.rb', line 46 def depends_on depended_on_by_references.map{|n|n.depends_on} end |
#inspect ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/artifacts/artifact.rb', line 62 def inspect indentation = ' '*(YAML_Model.next_oid.to_s.length + 1) "#{to_s}\n" + indentation + 'created : ' + created.to_s + "\n" + ( closed ? (indentation + 'closed : ' + closed.to_s + "\n" ) : '' ) + ( .size > 0 ? (indentation + 'tags : [' + .map{|n|n.name}.join(',') + "]\n" ) : '' ) + ( depended_on_by.size > 0 ? (indentation + 'depended on by : [' + depended_on_by.map{|n|n.id}.join(',') + "]\n" ) : '' ) + ( depends_on.size > 0 ? (indentation + 'depends on : [' + depends_on.map{|n|n.id}.join(',') + "]\n" ) : '' ) + ( comments.size > 0 ? (indentation + "comments :\n" + comments.join("\n")) : '' ) end |
#open? ⇒ Boolean
26 27 28 |
# File 'lib/artifacts/artifact.rb', line 26 def open? closed == nil end |
#open_depended_on_by ⇒ Object
50 51 52 |
# File 'lib/artifacts/artifact.rb', line 50 def open_depended_on_by depended_on_by.select{|n|!n.closed} end |
#open_depends_on ⇒ Object
42 43 44 |
# File 'lib/artifacts/artifact.rb', line 42 def open_depends_on depends_on.select{|n|!n.closed} end |
#priority ⇒ Object
73 74 75 76 77 |
# File 'lib/artifacts/artifact.rb', line 73 def priority open_depended_on_by.inject( @priority ) do |priority,artifact| priority += artifact.priority end end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/artifacts/artifact.rb', line 58 def to_s "%#{YAML_Model.next_oid.to_s.length}d #{depended_on_by.size > 0 ? 'd' : '-'}#{depends_on.size > 0 ? 'D' : '-'}#{comments.size > 0 ? 'c' : '-'} %#{self.class.priority_width}s #{summary}"%[id,closed ? 'X' : ( priority == 0 ? '' : priority.to_s )] end |