Module: Musa::Datasets::E

Includes:
Dataset
Included in:
Abs, Delta
Defined in:
lib/musa-dsl/datasets/e.rb

Overview

Base module for musical events.

E (Event) is the base module for all dataset types representing musical events. It provides validation interface and defines the concept of "natural keys" - keys that are inherent to the dataset type.

Natural Keys

Each dataset type defines which keys are "natural" to it (i.e., semantically meaningful for that type). Keys not in NaturalKeys are considered modifiers or extensions.

Validation

Events can be validated to ensure they contain required keys and valid values. Subclasses should override #valid? to implement type-specific validation.

Examples:

Basic validation

event = { pitch: 60, duration: 1.0 }.extend(Musa::Datasets::E)
event.valid?     # => true
event.validate!  # Returns if valid, raises if not

See Also:

Constant Summary collapse

NaturalKeys =

Natural keys for base events (empty).

Returns:

[].freeze

Instance Method Summary collapse

Instance Method Details

#valid?Boolean

Checks if event is valid.

Base implementation always returns true. Subclasses should override to implement specific validation logic.

Examples:

event.valid?  # => true

Returns:

  • (Boolean)

    true if valid



44
45
46
# File 'lib/musa-dsl/datasets/e.rb', line 44

def valid?
  true
end

#validate!void

This method returns an undefined value.

Validates event, raising if invalid.

Examples:

event.validate!  # Raises if invalid

Raises:

  • (RuntimeError)

    if event is not valid



55
56
57
# File 'lib/musa-dsl/datasets/e.rb', line 55

def validate!
  raise RuntimeError, "Invalid dataset #{self}" unless valid?
end