Class: DocTemplate::Objects::BaseMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_template/objects/base_metadata.rb

Class Method Summary collapse

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

Parameters:

  • text (String)

    text to be split

  • separator (String) (defaults to: DocTemplate::Tables::Base::SPLIT_REGEX)

Returns:

  • (Array)

    array of 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