Class: Kanal::Core::Interfaces::Interface
- Inherits:
-
Object
- Object
- Kanal::Core::Interfaces::Interface
- 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
Direct Known Subclasses
Instance Attribute Summary collapse
-
#core ⇒ Object
readonly
Returns the value of attribute core.
Instance Method Summary collapse
- #consume_input(input) ⇒ Object
- #consume_output(output) ⇒ Object
-
#initialize(core) ⇒ Interface
constructor
Interface makes all neded configuration, plugin registrations, properties registration in the constructor, which requires core.
- #modify_core(&block) ⇒ Object
-
#router ⇒ Kanal::Core::Router::Router
Returns default router from core.
-
#start ⇒ void
Starting the interface, all the needed machinery for it to fire up goes here.
-
#stop ⇒ <Type>
Yet to be discovered how to use this.
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.
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
#core ⇒ Object (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
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 |
#router ⇒ Kanal::Core::Router::Router
Returns default router from core
39 40 41 |
# File 'lib/kanal/core/interfaces/interface.rb', line 39 def router @core.router end |
#start ⇒ void
This method returns an undefined value.
Starting the interface, all the needed machinery for it to fire up goes here
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?
64 65 66 |
# File 'lib/kanal/core/interfaces/interface.rb', line 64 def stop raise NotImplementedError end |