Sha256: 70abdd4beacfd6435a653f69a6c291f5d8a978736bc360e8c72803aabfb807f7

Contents?: true

Size: 474 Bytes

Versions: 4

Compression:

Stored size: 474 Bytes

Contents

require 'virtus'

require_relative 'line'
require_relative 'coercions'

module Vedeu
  class InvalidLine < StandardError; end

  class LineCollection < Virtus::Attribute
    include Coercions

    def coerce(values)
      return [] if empty?(values)

      if multiple?(values)
        values.map { |v| Line.new(v) }

      elsif single?(values)
        [Line.new(values)]

      elsif just_text?(values)
        [Line.new({ streams: values })]

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.0.29 lib/vedeu/models/line_collection.rb
vedeu-0.0.28 lib/vedeu/models/line_collection.rb
vedeu-0.0.27 lib/vedeu/models/line_collection.rb
vedeu-0.0.26 lib/vedeu/models/line_collection.rb