Class: Silva::System::Base
- Inherits:
-
Object
- Object
- Silva::System::Base
- Defined in:
- lib/silva/system/base.rb
Overview
Provides basic utility functions.
Constant Summary collapse
- DEFAULT_PARAMS =
Default parameters can be specified for each system.
{}
- REQUIRED_PARAMS =
Some parameters must be given
[]
Instance Method Summary collapse
-
#initialize(options) ⇒ Base
constructor
Create the given system with relevant options.
-
#to(target_system_name, options = nil) ⇒ Silva::System
Transforms the base system to a different system.
Constructor Details
#initialize(options) ⇒ Base
Create the given system with relevant options.
17 18 19 20 21 22 |
# File 'lib/silva/system/base.rb', line 17 def initialize() @system_name = self.class.name.split('::').last.downcase.to_sym = self.class::DEFAULT_PARAMS.merge() params_satisfied?() .each {|param, val| set_param(param, val) } end |
Instance Method Details
#to(target_system_name, options = nil) ⇒ Silva::System
Transforms the base system to a different system.
30 31 32 33 34 35 36 37 |
# File 'lib/silva/system/base.rb', line 30 def to(target_system_name, = nil) return self if target_system_name == @system_name to_method = "to_#{target_system_name}".to_sym unless respond_to?(to_method, true) raise Silva::InvalidTransformError, "#{@system_name} cannot be transformed to #{target_system_name}." end send(to_method, ) end |