Class: Legion::Gaia::ChannelAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/gaia/channel_adapter.rb

Constant Summary collapse

DIRECT_ADDRESS_PATTERN =
/\bgaia\b/i

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel_id:, capabilities: []) ⇒ ChannelAdapter

Returns a new instance of ChannelAdapter.



23
24
25
26
27
# File 'lib/legion/gaia/channel_adapter.rb', line 23

def initialize(channel_id:, capabilities: [])
  @channel_id = channel_id
  @capabilities = capabilities
  @started = false
end

Class Attribute Details

.adapter_classesObject (readonly)

Returns the value of attribute adapter_classes.



11
12
13
# File 'lib/legion/gaia/channel_adapter.rb', line 11

def adapter_classes
  @adapter_classes
end

Instance Attribute Details

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



6
7
8
# File 'lib/legion/gaia/channel_adapter.rb', line 6

def capabilities
  @capabilities
end

#channel_idObject (readonly)

Returns the value of attribute channel_id.



6
7
8
# File 'lib/legion/gaia/channel_adapter.rb', line 6

def channel_id
  @channel_id
end

Class Method Details

.from_settings(_settings) ⇒ Object



29
30
31
# File 'lib/legion/gaia/channel_adapter.rb', line 29

def self.from_settings(_settings)
  nil
end

.inherited(subclass) ⇒ Object



17
18
19
20
# File 'lib/legion/gaia/channel_adapter.rb', line 17

def inherited(subclass)
  super
  register_adapter(subclass)
end

.register_adapter(klass) ⇒ Object



13
14
15
# File 'lib/legion/gaia/channel_adapter.rb', line 13

def register_adapter(klass)
  @adapter_classes << klass unless @adapter_classes.include?(klass)
end

Instance Method Details

#deliver(output_frame) ⇒ Object

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/legion/gaia/channel_adapter.rb', line 53

def deliver(output_frame)
  raise NotImplementedError, "#{self.class}#deliver must be implemented"
end

#startObject



33
34
35
# File 'lib/legion/gaia/channel_adapter.rb', line 33

def start
  @started = true
end

#started?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/legion/gaia/channel_adapter.rb', line 41

def started?
  @started
end

#stopObject



37
38
39
# File 'lib/legion/gaia/channel_adapter.rb', line 37

def stop
  @started = false
end

#supports?(capability) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/legion/gaia/channel_adapter.rb', line 59

def supports?(capability)
  capabilities.include?(capability)
end

#translate_inbound(raw_input) ⇒ Object

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/legion/gaia/channel_adapter.rb', line 45

def translate_inbound(raw_input)
  raise NotImplementedError, "#{self.class}#translate_inbound must be implemented"
end

#translate_outbound(output_frame) ⇒ Object

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/legion/gaia/channel_adapter.rb', line 49

def translate_outbound(output_frame)
  raise NotImplementedError, "#{self.class}#translate_outbound must be implemented"
end