Class: Musa::Darwin::Darwin::MainContext Private

Inherits:
Object
  • Object
show all
Includes:
Extension::With
Defined in:
lib/musa-dsl/generative/darwin.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

DSL context for Darwin configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ MainContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MainContext.



193
194
195
196
# File 'lib/musa-dsl/generative/darwin.rb', line 193

def initialize(&block)
  @_weights = {}
  with &block
end

Instance Attribute Details

#_measuresProc, Hash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)

    measures evaluation block

  • (Hash)

    weight assignments



190
191
192
# File 'lib/musa-dsl/generative/darwin.rb', line 190

def _measures
  @_measures
end

#_weightsProc, Hash (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)

    measures evaluation block

  • (Hash)

    weight assignments



190
191
192
# File 'lib/musa-dsl/generative/darwin.rb', line 190

def _weights
  @_weights
end

Instance Method Details

#measures {|object| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Defines measures evaluation block.

Yields:

  • (object)

    measures DSL block



202
203
204
# File 'lib/musa-dsl/generative/darwin.rb', line 202

def measures(&block)
  @_measures = block
end

#weight(**feature_or_dimension_weights) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Assigns weights to features/dimensions.

Parameters:

  • feature_or_dimension_weights (Hash)

    name => weight pairs



210
211
212
213
214
# File 'lib/musa-dsl/generative/darwin.rb', line 210

def weight(**feature_or_dimension_weights)
  feature_or_dimension_weights.each do |name, value|
    @_weights[name] = value
  end
end

#with(*value_parameters, keep_block_context: nil, **key_parameters, &block) ⇒ Object Originally defined in module Extension::With

Note:

The _ parameter is special: when present, it signals "keep caller's context" and receives self (the object) as its value.

Note:

Uses SmartProcBinder internally to handle parameter matching.

Executes a block with flexible context and parameter handling.

Parameters:

  • value_parameters (Array)

    positional parameters to pass to block.

  • keep_block_context (Boolean, nil) (defaults to: nil)

    explicit control of context switching:

    • true: always keep caller's context
    • false: always use object's context
    • nil: auto-detect based on _ parameter
  • key_parameters (Hash)

    keyword parameters to pass to block.

  • block (Proc)

    block to execute.

Returns:

  • (Object)

    result of block execution.