Ravn::BDE::

Segment class

This is the base class for segments, which provides a way of grouping users together with late binding for messaging. It is fundamentally a function over all callsigns in a mission that yields a Set. These can be combined using set algebra to describe a dynamic grouping of message recipients, allowed message senders, etc.

      "within 10 meters":
        type: proximity
        config:
          distance: 10
      "within 100 meters":
        type: proximity
        config:
          distance: 100
      "squad leaders":
        type: group
        config:
          members: []

There is a special instance of the base class that is the default (or “all”) segment.

Constants

DEFAULT_SEGMENT_NAME

The name of the default segment

DELEGATION_EXCEPTIONS

Methods to not delegate to the underlying Set.

Attributes

config R

Segment specific keyword arguments.

member_candidates R

The call-able that yields the initial set of members.

name R

The human-readable name of this Segment

Public Class Methods

default()

Returns a default (everyone) segment.

# File lib/ravn/bde/segment.rb, line 63
def self::default
        return @default ||= self.new( DEFAULT_SEGMENT_NAME )
end
new( name, **config, &member_candidates )

Set up a new segment with the given (human-readable) name and initial set of member_candidates (anything Enumerable).

# File lib/ravn/bde/segment.rb, line 70
def initialize( name, **config, &member_candidates )
        @name = name
        @config = config
        @member_candidates = member_candidates || Ravn::BDE.method( :callsigns )
end
validate( config, mission )

Ensure the given config makes sense for the segment type in the given mission, raising a Ravn::BDE::ValidationError if not.

# File lib/ravn/bde/segment.rb, line 57
def self::validate( config, mission )
        # Defaults to always valid
end

Public Instance Methods

==( other_object )

Equality API – returns true if the other_object is equivalent

# File lib/ravn/bde/segment.rb, line 111
def ==( other_object )
        return other_object.is_a?( self.class ) &&
                other_object.name == self.name &&
                other_object.config == self.config &&
                other_object.member_candidates == self.member_candidates
end
members()

Return a subset of the members returned by the member_candidates callable.

# File lib/ravn/bde/segment.rb, line 99
def members
        return self.member_candidates.call.to_set
end
ravn/bde/segment()

Pluggability API: path to search for child classes

# File lib/ravn/bde/segment.rb, line 48
plugin_prefixes 'ravn/bde/segment'
ravn_bde()

Loggability API: log to the Ravn::BDE logger

# File lib/ravn/bde/segment.rb, line 52
log_to :ravn_bde
to_h()

Return the current segment members as a Hash keyed by callsign.

# File lib/ravn/bde/segment.rb, line 105
def to_h
        return self.members.to_h {|callsign| [callsign, nil] }
end