Class: Diamond::Pattern

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Defined in:
lib/diamond/pattern.rb

Overview

Pattern that the sequence is derived from given the parameters and input

Defined Under Namespace

Modules: ClassMethods, Presets

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

<<, add, all, find, first, last

Constructor Details

#initialize(name, &block) ⇒ Pattern

Returns a new instance of Pattern

Parameters:

  • name (String, Symbol)

    A name to identify the pattern by eg “up/down”

  • block (Proc)

    The pattern procedure, which should return an array of scale degree numbers.

    For example, given the arguments (3, 7) the “Up” pattern will produce [0, 7, 14, 21]



55
56
57
58
# File 'lib/diamond/pattern.rb', line 55

def initialize(name, &block)
  @name = name
  @proc = block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name



50
51
52
# File 'lib/diamond/pattern.rb', line 50

def name
  @name
end

Instance Method Details

#compute(range, interval) ⇒ Array<Fixnum>

Compute scale degrees using the pattern with the given range and interval

Parameters:

  • range (Fixnum)
  • interval (Interval)

Returns:

  • (Array<Fixnum>)


64
65
66
# File 'lib/diamond/pattern.rb', line 64

def compute(range, interval)
  @proc.call(range, interval)
end