Class: Zgomot::Comp::Mode

Inherits:
Object show all
Defined in:
lib/zgomot/comp/mode.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode = 1) ⇒ Mode

Returns a new instance of Mode.



19
20
21
22
23
24
25
26
27
# File 'lib/zgomot/comp/mode.rb', line 19

def initialize(mode = 1)
  @mode = case mode
             when Symbol then self.class.modes.index(mode)+1
             when Fixnum then mode % 7
             when nil then 1
             else raise(Zgomot::Error, "#{mode.inspect} is invalid mode")
           end
  @scale = Scale.new(self.class.intervals, @mode)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



33
34
35
# File 'lib/zgomot/comp/mode.rb', line 33

def method_missing(meth, *args, &blk )
  scale.send(meth, *args, &blk)
end

Class Attribute Details

.chordsObject (readonly)

Returns the value of attribute chords.



14
15
16
# File 'lib/zgomot/comp/mode.rb', line 14

def chords
  @chords
end

.intervalsObject (readonly)

Returns the value of attribute intervals.



14
15
16
# File 'lib/zgomot/comp/mode.rb', line 14

def intervals
  @intervals
end

.modesObject (readonly)

Returns the value of attribute modes.



14
15
16
# File 'lib/zgomot/comp/mode.rb', line 14

def modes
  @modes
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



17
18
19
# File 'lib/zgomot/comp/mode.rb', line 17

def mode
  @mode
end

#scaleObject (readonly)

Returns the value of attribute scale.



17
18
19
# File 'lib/zgomot/comp/mode.rb', line 17

def scale
  @scale
end

Instance Method Details

#chords(chord = :scale) ⇒ Object



29
30
31
# File 'lib/zgomot/comp/mode.rb', line 29

def chords(chord = :scale)
  cycle_chords(Mode.chords[chord].clone)
end