Class: Factorix::API::License
- Inherits:
-
Data
- Object
- Data
- Factorix::API::License
- Defined in:
- lib/factorix/api/license.rb,
lib/factorix/api/license.rb
Overview
License object from MOD Portal API
Represents a MOD license information. Uses flyweight pattern for standard licenses. Also provides valid license identifiers for edit_details API.
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
License description (long text).
-
#id ⇒ String
readonly
License ID.
-
#name ⇒ String
readonly
License name.
-
#title ⇒ String
readonly
License title.
-
#url ⇒ URI::HTTPS
readonly
License URL.
Class Method Summary collapse
-
.for(id) ⇒ License
Get License instance for the given identifier.
-
.identifiers ⇒ Array<String>
All license identifiers.
-
.valid_identifier?(value) ⇒ Boolean
Check if the given value is a valid license identifier.
Instance Method Summary collapse
-
#initialize(id:, name:, title:, description:, url:) ⇒ License
constructor
New License instance.
Constructor Details
#initialize(id:, name:, title:, description:, url:) ⇒ License
Returns new License instance.
121 122 123 124 |
# File 'lib/factorix/api/license.rb', line 121 def initialize(id:, name:, title:, description:, url:) url = URI(url) super end |
Instance Attribute Details
#description ⇒ String (readonly)
Returns license description (long text).
18 19 20 |
# File 'lib/factorix/api/license.rb', line 18 def description @description end |
#id ⇒ String (readonly)
Returns license ID.
18 19 20 |
# File 'lib/factorix/api/license.rb', line 18 def id @id end |
#name ⇒ String (readonly)
Returns license name.
18 19 20 |
# File 'lib/factorix/api/license.rb', line 18 def name @name end |
#title ⇒ String (readonly)
Returns license title.
18 19 20 |
# File 'lib/factorix/api/license.rb', line 18 def title @title end |
#url ⇒ URI::HTTPS (readonly)
Returns license URL.
18 19 20 |
# File 'lib/factorix/api/license.rb', line 18 def url @url end |
Class Method Details
.for(id) ⇒ License
Get License instance for the given identifier
Returns predefined instance for known licenses (flyweight pattern). Raises an error for unknown license identifiers.
105 |
# File 'lib/factorix/api/license.rb', line 105 def self.for(id) = LICENSES.fetch(id.to_s) |
.identifiers ⇒ Array<String>
Returns all license identifiers.
95 |
# File 'lib/factorix/api/license.rb', line 95 def self.identifiers = LICENSES.keys |
.valid_identifier?(value) ⇒ Boolean
Check if the given value is a valid license identifier
111 112 113 |
# File 'lib/factorix/api/license.rb', line 111 def self.valid_identifier?(value) LICENSES.key?(value) || CUSTOM_LICENSE_PATTERN.match?(value) end |