Class: DocTemplate::Objects::BaseMetadata
- Inherits:
-
Object
- Object
- DocTemplate::Objects::BaseMetadata
- Defined in:
- lib/doc_template/objects/base_metadata.rb
Class Method Summary collapse
- .build_from(data) ⇒ Object
-
.split_field(text, separator = DocTemplate::Tables::Base::SPLIT_REGEX) ⇒ Array
Splits the text by separator removing empty parts.
Class Method Details
.build_from(data) ⇒ Object
28 29 30 31 |
# File 'lib/doc_template/objects/base_metadata.rb', line 28 def build_from(data) copy = data&.transform_keys { |k| k.to_s.underscore } new(copy.presence || {}) end |
.split_field(text, separator = DocTemplate::Tables::Base::SPLIT_REGEX) ⇒ Array
Splits the text by separator removing empty parts
40 41 42 43 44 |
# File 'lib/doc_template/objects/base_metadata.rb', line 40 def split_field(text, separator = DocTemplate::Tables::Base::SPLIT_REGEX) text.to_s .split(separator) .map(&:squish).reject(&:blank?) end |