Class: Spandx::Spdx::CompositeLicense
- Inherits:
-
License
- Object
- License
- Spandx::Spdx::CompositeLicense
show all
- Defined in:
- lib/spandx/spdx/composite_license.rb
Instance Attribute Summary
Attributes inherited from License
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from License
#<=>, #deprecated_license_id?, #id=, #inspect, #name=, #osi_approved?, #reference, #reference=, #reference_number, #reference_number=, #see_also, #to_s, unknown, #url, #url=
Constructor Details
Returns a new instance of CompositeLicense.
13
14
15
16
17
|
# File 'lib/spandx/spdx/composite_license.rb', line 13
def initialize(tree, catalogue)
@catalogue = catalogue
@tree = tree
super({})
end
|
Class Method Details
.from_expression(expression, catalogue) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/spandx/spdx/composite_license.rb', line 6
def self.from_expression(expression, catalogue)
tree = Spdx::Expression.new.parse(expression)
new(tree[0], catalogue)
rescue Parslet::ParseFailed
nil
end
|
Instance Method Details
#id ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/spandx/spdx/composite_license.rb', line 19
def id
if right
[left.id, operator, right.id].compact.join(' ').squeeze(' ').strip
else
left.id.to_s
end
end
|
#name ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/spandx/spdx/composite_license.rb', line 27
def name
if right
[left.name, operator, right.name].compact.join(' ').squeeze(' ').strip
else
left.name
end
end
|