Module: Emendate::Subsourceable

Defined in:
lib/emendate/subsourceable.rb

Overview

Consolidates the logic for returning subsources for Segment, DateTypes::Range, the other date type classes, and SegmentSet

Instance Method Summary collapse

Instance Method Details

#subsources(as: :segset) ⇒ Emendate::SegmentSet, Array<Emendate::Segment>

Parameters:

  • as (:segset, :arr) (defaults to: :segset)

    how to return the subsources; for general use, pass no value and a SegmentSet will be returned. The :arr value is used in implementing the logic here, and can be used elsewhere in cases where you want a plain Array of Segments instead of a SegmentSet

Returns:

  • (Emendate::SegmentSet)

    if as: :segset

  • (Array<Emendate::Segment>)

    if as: :arr



15
16
17
18
19
20
# File 'lib/emendate/subsourceable.rb', line 15

def subsources(as: :segset)
  result = subsource_segments.flatten
  return result unless as == :segset

  Emendate::SegmentSet.new(segments: result)
end