Class: Gemterms::Project
- Inherits:
-
Object
- Object
- Gemterms::Project
- Defined in:
- lib/gemterms/project.rb
Overview
A collection of components to be evaluated as a set.
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
Instance Method Summary collapse
- #<<(component) ⇒ Object
- #components_for_license(license) ⇒ Object
-
#count ⇒ int
Number of components in the project.
-
#count_unlicensed ⇒ int
licenses.
-
#initialize ⇒ Project
constructor
A new instance of Project.
- #licenses(include_unknown = true) ⇒ Object
-
#unique_licenses(include_unknown = true) ⇒ Array<License>
included in the returned list.
Constructor Details
#initialize ⇒ Project
Returns a new instance of Project.
50 51 52 |
# File 'lib/gemterms/project.rb', line 50 def initialize @components = [] end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
29 30 31 |
# File 'lib/gemterms/project.rb', line 29 def components @components end |
Instance Method Details
#<<(component) ⇒ Object
31 32 33 |
# File 'lib/gemterms/project.rb', line 31 def <<(component) @components << component end |
#components_for_license(license) ⇒ Object
46 47 48 |
# File 'lib/gemterms/project.rb', line 46 def components_for_license(license) @components.select { |c| c.licenses.include?(license) } end |
#count ⇒ int
Returns number of components in the project.
36 37 38 |
# File 'lib/gemterms/project.rb', line 36 def count @components.length end |
#count_unlicensed ⇒ int
licenses
42 43 44 |
# File 'lib/gemterms/project.rb', line 42 def count_unlicensed @components.count { |c| c.licensed? } end |
#licenses(include_unknown = true) ⇒ Object
54 55 56 57 58 |
# File 'lib/gemterms/project.rb', line 54 def licenses(include_unknown = true) result = @components.map { |c| c.licenses }.flatten result.reject! { |l| l.unknown? } unless include_unknown result end |
#unique_licenses(include_unknown = true) ⇒ Array<License>
included in the returned list. Defaults to true.
project.
65 66 67 |
# File 'lib/gemterms/project.rb', line 65 def unique_licenses(include_unknown = true) self.licenses.uniq end |