Class: Kanal::Core::Interfaces::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/kanal/core/interfaces/interface.rb

Overview

Basic class of interface - interface is basically what is creating inputs and consumes output from the routers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core) ⇒ Interface

Interface makes all neded configuration, plugin registrations, properties registration in the constructor, which requires core. Originally, there was thoughts of interfaces as top level building blocks for ecosystem, this is why interfaces are doing stuff with core inside constructors. It was originally thought that main application file will host like multiple interfaces. This is also why interfaces had no argument core in constructor, because they created cores inside.

Parameters:



25
26
27
28
29
30
31
32
# File 'lib/kanal/core/interfaces/interface.rb', line 25

def initialize(core)
  @core = core

  _this = self
  @core.router.output_ready do |output|
    _this.consume_output output
  end
end

Instance Attribute Details

#coreObject (readonly)

Returns the value of attribute core.



11
12
13
# File 'lib/kanal/core/interfaces/interface.rb', line 11

def core
  @core
end

Instance Method Details

#consume_input(input) ⇒ Object



68
69
70
# File 'lib/kanal/core/interfaces/interface.rb', line 68

def consume_input(input)
  @core.router.consume_input input
end

#consume_output(output) ⇒ Object

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/kanal/core/interfaces/interface.rb', line 72

def consume_output(output)
  raise NotImplementedError
end

#modify_core(&block) ⇒ Object



43
44
45
# File 'lib/kanal/core/interfaces/interface.rb', line 43

def modify_core(&block)
  block.call @core
end

#routerKanal::Core::Router::Router

Returns default router from core

Returns:



39
40
41
# File 'lib/kanal/core/interfaces/interface.rb', line 39

def router
  @core.router
end

#startvoid

This method returns an undefined value.

Starting the interface, all the needed machinery for it to fire up goes here

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/kanal/core/interfaces/interface.rb', line 53

def start
  raise NotImplementedError
end

#stop<Type>

Yet to be discovered how to use this. If method #start executes some synchronous code, how would we stop it from outside? I mean maybe with some kind of flag variable inside?

Returns:

  • (<Type>)

    <description>

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/kanal/core/interfaces/interface.rb', line 64

def stop
  raise NotImplementedError
end