Class Eymiha::Envelope
In: lib/eymiha/util/envelope.rb
Parent: BaseEnvelope

An Envelope is the minimum envelope that will completely contain a set of values. Values may be added to an instance, and it can return the number of values considered so far and its high and low boundaries.

Envelopes can be used to generate ranges, however the result may be of limited utility if the types of values being enveloped don‘t play nicely with ranges.

Methods

===   add   contains?   high   low   new   to_range   to_s  

Public Class methods

Creates and returns an instance. If an argument is given, it is passed to the set method to initialize the new instance.

Public Instance methods

===(value)

Alias for contains?

Adds a value to the instance. When

  • x is an Envelope, it is coalesced into the instance.
  • otherwise, the envelope is extened to contain the value.
  • if the value cannot be compared to the boundaries, an EnvelopeException is raised.

The modified instance is returned.

Returns true if the instance completely contains the argument:

  • value is an Envelope, its high and low are contained.
  • otherwise, the value is contained.
  • if the value cannot be compared to the boundaries, an EnvelopeException is raised.

Returns the high boundary of the instance.

Returns the low boundary of the instance.

Returns an inclusive range from the low to high boundaries

Returns a string representation of the instance.

[Validate]