Class: Evoasm::Population::SeedBuilder::Kernel
- Inherits:
-
Object
- Object
- Evoasm::Population::SeedBuilder::Kernel
- Defined in:
- lib/evoasm/population/seed_builder.rb
Instance Attribute Summary collapse
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
Instance Method Summary collapse
- #default(default = nil) ⇒ Object
-
#initialize(builder, &block) ⇒ Kernel
constructor
A new instance of Kernel.
- #method_missing(name, *args, **kwargs, &block) ⇒ Object
- #respond_to_missing?(name, *args, **kwargs, &block) ⇒ Boolean
Constructor Details
#initialize(builder, &block) ⇒ Kernel
Returns a new instance of Kernel
11 12 13 14 15 16 |
# File 'lib/evoasm/population/seed_builder.rb', line 11 def initialize(builder, &block) @builder = builder @instructions = [] instance_eval &block if block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/evoasm/population/seed_builder.rb', line 28 def method_missing(name, *args, **kwargs, &block) if builder.instruction_name? name if builder.allowed_instruction_name? name @instructions << [name, kwargs] else raise ArgumentError, "'#{name}' is not in the current instruction set" end else super end end |
Instance Attribute Details
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions
9 10 11 |
# File 'lib/evoasm/population/seed_builder.rb', line 9 def instructions @instructions end |
Instance Method Details
#default(default = nil) ⇒ Object
23 24 25 26 |
# File 'lib/evoasm/population/seed_builder.rb', line 23 def default(default = nil) return @default if default.nil? @default = default end |
#respond_to_missing?(name, *args, **kwargs, &block) ⇒ Boolean
18 19 20 21 |
# File 'lib/evoasm/population/seed_builder.rb', line 18 def respond_to_missing?(name, *args, **kwargs, &block) return true if builder.instructions.include? name false end |