Ravn::Tactical::

Bolt class

A bolt-creation object for populating tailored Bolts in mission files.

Constants

DEFAULT_TEXT

The default message contents for a Bolt

DEFAULT_TIMEOUT

The default number of seconds after initiation before finishing the bolt

Attributes

components R

The bolt’s configured components

description RW

The bolt’s human-readable description

id RW

The bolt’s id

name RW

The bolt’s vernacular type

options R

Additional configuration options for the Bolt

text RW

The bolt’s message text

timeout RW

The bolt’s timeout

to R

Segment the bolt will be delivered to

type RW

The bolt’s canonical type

validation_error RW

The description of the problem the last time the Bolt was checked for validity.

Public Class Methods

new( **fields )

Create a new bolt description with the given fields.

   # File lib/ravn/tactical/bolt.rb
28 def initialize( **fields )
29     @id          = fields[:id] || Ravn.uuid.generate
30     @timeout     = fields[:timeout] || DEFAULT_TIMEOUT
31     @type        = fields[:type]
32     @name        = fields[:name]
33     @text        = fields[:text] || DEFAULT_TEXT
34     @to          = fields[:to]
35     @description = fields[:description]
36     @components  = fields[:components] || {}
37     @options     = fields[:options] || {}
38 
39     @validation_error = nil
40 end

Public Instance Methods

==( other_object )

Comparison API – returns true if other_object has the same fields as the receiver.

    # File lib/ravn/tactical/bolt.rb
131 def ==( other_object )
132     return other_object.is_a?( self.class ) &&
133         other_object.fields == self.fields
134 end
deconstruct_keys( * )

Pattern-matching API – return a Hash that is used when pattern-matching on this Bolt.

    # File lib/ravn/tactical/bolt.rb
139 def deconstruct_keys( * )
140     return self.fields
141 end
draft?()

Returns true if the Bolt is a draft, i.e., isn’t from the unit’s Bolt Library.

    # File lib/ravn/tactical/bolt.rb
107 def draft?
108     return self.name ? true : false
109 end
Also aliased as: is_draft?
fields()

Return a Hash of the Bolt’s values, suitable for addition to a Mission’s bolts section.

    # File lib/ravn/tactical/bolt.rb
 93 def fields
 94     return {
 95         type:       self.type,
 96         name:       self.name,
 97         text:       self.text,
 98         timeout:    self.timeout.to_i,
 99         to:         self.to,
100         components: self.components
101     }
102 end
inspect_details()

Ravn::Inspection API – return the details portion of the object’s debugging string form.

    # File lib/ravn/tactical/bolt.rb
145 def inspect_details
146     return "%s%s %p (timeout: %0.2fs), %d components" % [
147         self.type,
148         self.name ? ": #{self.name}" : '',
149         self.description || '-',
150         self.timeout,
151         self.components.size,
152     ]
153 end
is_draft?()
Alias for: draft?
valid?()

Returns true if the bolt’s values are valid. If the the Bolt isn’t valid, the validation_error will be set with a description of the validation problem.

    # File lib/ravn/tactical/bolt.rb
116 def valid?
117     self.validation_error = nil
118     Ravn::BDE::Bolt.validate( self.fields )
119 
120     return true
121 rescue Ravn::BDE::InvalidBoltConfig => err
122     self.log.debug { err.full_message }
123     self.validation_error = err.message
124 
125     return false
126 end