Class: LicenseScout::License::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/license_scout/license.rb

Overview

A class that represents the components that make up a license.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(license_id = nil, source = nil, content = nil, options = {}) ⇒ Record

Returns a new instance of Record.



30
31
32
33
34
35
# File 'lib/license_scout/license.rb', line 30

def initialize(license_id = nil, source = nil, content = nil, options = {})
  @id = LicenseScout::SPDX.find(license_id, options[:force])
  @parsed_expression = LicenseScout::SPDX.parse(id)
  @source = source
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



27
28
29
# File 'lib/license_scout/license.rb', line 27

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id.



24
25
26
# File 'lib/license_scout/license.rb', line 24

def id
  @id
end

#parsed_expressionObject (readonly)

Returns the value of attribute parsed_expression.



25
26
27
# File 'lib/license_scout/license.rb', line 25

def parsed_expression
  @parsed_expression
end

#sourceObject (readonly)

Returns the value of attribute source.



26
27
28
# File 'lib/license_scout/license.rb', line 26

def source
  @source
end

#spdx_license_dataObject (readonly)

Returns the value of attribute spdx_license_data.



28
29
30
# File 'lib/license_scout/license.rb', line 28

def spdx_license_data
  @spdx_license_data
end

Instance Method Details

#to_hObject



37
38
39
40
41
42
43
# File 'lib/license_scout/license.rb', line 37

def to_h
  {
    id: id,
    source: source,
    content: content,
  }
end