Sha256: 09f11572b1dd3b88f8a4ec41a81112337d5d303519cc9786a2b84ddcdf0891e4

Contents?: true

Size: 1.59 KB

Versions: 16

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

module DocTemplate
  module Objects
    class BaseMetadata
      include Virtus.model

      attribute :cc_attribution, String, default: ''
      attribute :description, String, default: ''
      attribute :grade, String, default: ''
      attribute :lesson, String, default: ''
      attribute :lesson_mathematical_practice, String, default: ''
      attribute :lesson_objective, String, default: ''
      attribute :lesson_standard, String, default: ''
      attribute :materials, String, default: ''
      attribute :module, String, default: ''
      attribute :preparation, String, default: ''
      attribute :resource_subject, String, default: ->(m, _) { m.subject.try(:downcase) }
      attribute :standard, String, default: ''
      attribute :subject, String, default: ''
      attribute :teaser, String, default: ''
      attribute :title, String, default: ''
      attribute :topic, String, default: ''
      attribute :type, String, default: 'core'
      attribute :unit, String, default: ''

      class << self
        def build_from(data)
          copy = data&.transform_keys { |k| k.to_s.underscore }
          new(copy.presence || {})
        end

        #
        # Splits the text by separator removing empty parts
        #
        # @param text [String] text to be split
        # @param separator [String]
        # @return [Array] array of parts
        #
        def split_field(text, separator = DocTemplate::Tables::Base::SPLIT_REGEX)
          text.to_s
            .split(separator)
            .map(&:squish).reject(&:blank?)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.5.4 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.5.3 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.5.2 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.5.1 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.5.0 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.4.2 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.4.1 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.4.0 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.3.1 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.1.4 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.3.0 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.1.3 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.2.0 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.1.2 lib/doc_template/objects/base_metadata.rb
lcms-engine-0.1.0 lib/doc_template/objects/base_metadata.rb