Class: Factorix::API::License

Inherits:
Data
  • Object
show all
Defined in:
lib/factorix/api/license.rb,
lib/factorix/api/license.rb

Overview

License object from MOD Portal API

Represents a MOD license information. Also provides valid license identifiers for edit_details API.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, title:, description:, url:) ⇒ License

Create License from API response hash

Parameters:

  • id (String)

    license ID

  • name (String)

    license name

  • title (String)

    license title

  • description (String)

    license description

  • url (String)

    license URL



65
66
67
68
# File 'lib/factorix/api/license.rb', line 65

def initialize(id:, name:, title:, description:, url:)
  url = URI(url)
  super
end

Instance Attribute Details

#descriptionString (readonly)

Returns license description (long text).

Returns:

  • (String)

    license description (long text)



17
18
19
# File 'lib/factorix/api/license.rb', line 17

def description
  @description
end

#idString (readonly)

Returns license ID.

Returns:

  • (String)

    license ID



17
18
19
# File 'lib/factorix/api/license.rb', line 17

def id
  @id
end

#nameString (readonly)

Returns license name.

Returns:

  • (String)

    license name



17
18
19
# File 'lib/factorix/api/license.rb', line 17

def name
  @name
end

#titleString (readonly)

Returns license title.

Returns:

  • (String)

    license title



17
18
19
# File 'lib/factorix/api/license.rb', line 17

def title
  @title
end

#urlURI::HTTPS (readonly)

Returns license URL.

Returns:

  • (URI::HTTPS)

    license URL



17
18
19
# File 'lib/factorix/api/license.rb', line 17

def url
  @url
end

Class Method Details

.identifier_valuesArray<String>

List all valid license identifier values

Returns:

  • (Array<String>)

    array of license identifiers



55
# File 'lib/factorix/api/license.rb', line 55

def self.identifier_values = IDENTIFIERS.keys

.valid_identifier?(value) ⇒ Boolean

Check if the given value is a valid license identifier

Parameters:

  • value (String)

    license identifier

Returns:

  • (Boolean)

    true if valid (standard or custom license)



48
49
50
# File 'lib/factorix/api/license.rb', line 48

def self.valid_identifier?(value)
  IDENTIFIERS.key?(value) || CUSTOM_LICENSE_PATTERN.match?(value)
end