Class: BaseEnvelope

Inherits:
Object
  • Object
show all
Defined in:
lib/envelope.rb

Overview

A BaseEnvelope provides a means to keep and provide a count of objects that have been added to an envelope.

Direct Known Subclasses

Envelope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBaseEnvelope

Returns a new instance with no values added.



34
35
36
# File 'lib/envelope.rb', line 34

def initialize
  @count = 0
end

Instance Attribute Details

#countObject (readonly)

count of added values reader.



31
32
33
# File 'lib/envelope.rb', line 31

def count
  @count
end

Instance Method Details

#raise_no_compare(value = nil) ⇒ Object

Called when the value cannot be compared with the the boundaries of the instance.

Raises:



24
25
26
27
28
# File 'lib/envelope.rb', line 24

def raise_no_compare(value=nil)
  value = "'#{value}' " unless value == nil
  raise EnvelopeException,
    "The value #{value}cannot be compared with the envelope"
end

#raise_no_envelopeObject

Called when requesting envelope bounderies before any values have been added.

Raises:



18
19
20
# File 'lib/envelope.rb', line 18

def raise_no_envelope
  raise EnvelopeException, "No values are enveloped"
end