Sha256: f6679adf9ae94e6055094c0791b6dc4c3d3d0eeff3a3bbd1d7438d10f05c80bb

Contents?: true

Size: 1.36 KB

Versions: 10

Compression:

Stored size: 1.36 KB

Contents

module Saxon
  module XDM
    # Mixin for objects that are XDM Sequence-like in behaviour
    module SequenceLike
      # Implementors should return an {Enumerator} over the Sequence. For
      # {XDM::Value}s, this will just be the items in the sequence. For
      # XDM::AtomicValue or XDM::Node, this will be a single-item Enumerator so
      # that Items can be correctly treated as single-item Values.
      def sequence_enum
        raise NotImplementedError
      end

      # Implementors should return the size of the Sequence. For
      # {XDM::AtomicValue} this will always be 1.
      # @return [Integer] the sequence size
      def sequence_size
        raise NotImplementedError
      end

      # Return a new XDM::Value from this Sequence with the passed in value
      # appended to the end.
      # @return [XDM::Value] the new Value
      def append(other)
        XDM::Value.create([self, other])
      end

      alias_method :<<, :append
      alias_method :+, :append
    end

    # Mixin for objects that are Sequence-like but only contain a single item,
    # like {XDM::AtomicValue} or {XDM::Node}
    module ItemSequenceLike
      # return a single-item Enumerator containing +self+
      def sequence_enum
        [self].to_enum
      end

      # Returns the sequence size, which will always be 1.
      def sequence_size
        1
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
saxon-rb-0.8.3-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.8.2-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.8.1-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.8.0-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.7.3-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.7.2-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.7.1-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.7.0-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.6.0-java lib/saxon/xdm/sequence_like.rb
saxon-rb-0.5.0-java lib/saxon/xdm/sequence_like.rb