Module ModeContext
In: app/models/mode_context.rb

Mode context is a module intended to be mixed in to classes requiring the notion of "mode context". Right now the only class that uses this is scale. Mode context allows scales to take on a mode context which effectively offsets tone sequences to retrieve tones in the given scale mode.

  • +in_mode(new_mode)+ - Sets the mode context to the specified mode (integer).
  • without_mode - Removes mode context.

Methods

Public Class methods

[Source]

    # File app/models/mode_context.rb, line 10
10:         def self.included(klass)
11:                 klass.class_eval do
12:                         attr_accessor :mode
13:                         
14:                         def in_mode(value)
15:                                 if value.is_a?(String)
16:                                         mode_object = self.respond_to?(:modes) ? self.modes.find_by_name(value) : Mode.find_by_name(value)
17:                                         self.mode = mode_object.mode unless mode_object.nil?
18:                                 else
19:                                         self.mode = value
20:                                 end
21:                                 self
22:                         end
23:                         
24:                         def without_mode
25:                                 self.mode = nil
26:                                 self
27:                         end
28:                 end
29:         end

Public Instance methods

[Source]

    # File app/models/mode_context.rb, line 14
14:                         def in_mode(value)
15:                                 if value.is_a?(String)
16:                                         mode_object = self.respond_to?(:modes) ? self.modes.find_by_name(value) : Mode.find_by_name(value)
17:                                         self.mode = mode_object.mode unless mode_object.nil?
18:                                 else
19:                                         self.mode = value
20:                                 end
21:                                 self
22:                         end

[Source]

    # File app/models/mode_context.rb, line 24
24:                         def without_mode
25:                                 self.mode = nil
26:                                 self
27:                         end

[Validate]