Class: Pdfh::Settings
- Inherits:
-
Object
- Object
- Pdfh::Settings
- Defined in:
- lib/pdfh/models/settings.rb
Overview
Handles the config yaml data mapping, and associates a file name with a doc type. This is a pure data object — validation is handled by Services::SettingsValidator.
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#lookup_dirs ⇒ Array<String>
readonly
List of validated, expanded directories to look up for processing.
Instance Method Summary collapse
- #document_type(id) ⇒ DocumentType
- #document_types ⇒ Array<DocumentType>
- #document_types_name_max_size ⇒ Integer
- #initialize(lookup_dirs:, base_path:, document_types:) ⇒ Settings constructor
Constructor Details
#initialize(lookup_dirs:, base_path:, document_types:) ⇒ Settings
17 18 19 20 21 |
# File 'lib/pdfh/models/settings.rb', line 17 def initialize(lookup_dirs:, base_path:, document_types:) @lookup_dirs = lookup_dirs @base_path = base_path @document_types = document_types end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
11 |
# File 'lib/pdfh/models/settings.rb', line 11 attr_reader :lookup_dirs, :base_path |
#lookup_dirs ⇒ Array<String> (readonly)
Returns List of validated, expanded directories to look up for processing.
11 12 13 |
# File 'lib/pdfh/models/settings.rb', line 11 def lookup_dirs @lookup_dirs end |
Instance Method Details
#document_type(id) ⇒ DocumentType
37 38 39 |
# File 'lib/pdfh/models/settings.rb', line 37 def document_type(id) @document_types[id] end |
#document_types ⇒ Array<DocumentType>
24 |
# File 'lib/pdfh/models/settings.rb', line 24 def document_types = @document_types.values |
#document_types_name_max_size ⇒ Integer
30 31 32 33 34 |
# File 'lib/pdfh/models/settings.rb', line 30 def document_types_name_max_size return 0 if document_types.empty? document_types.map { _1.name.length }.max end |