Class: Tonal::Comma

Inherits:
Object
  • Object
show all
Defined in:
lib/tonal/comma.rb

Class Method Summary collapse

Class Method Details

.commasHash

Returns of comma key/value pairs.

Examples:

Tonal::Comma.commas
=> {"diaschisma"=>"2048/2025",
    "dicot"=>"25/24",
    "dieses1"=>"648/625",
    ...}

Returns:

  • (Hash)

    of comma key/value pairs



10
11
12
# File 'lib/tonal/comma.rb', line 10

def self.commas
  @commas ||= JSON.parse(YAML::load_file("#{__dir__}/../../data/commas.yml", aliases: true).to_json)["commas"]
end

.keysArray

Returns of comma keys.

Examples:

Tonal::Comma.keys
=> ["diaschisma", "dicot", "dieses1", ...]

Returns:

  • (Array)

    of comma keys



28
29
30
# File 'lib/tonal/comma.rb', line 28

def self.keys
  @keys ||= commas.keys
end

.method_missing(comma) ⇒ Rational

Returns the comma found in the repo.

Examples:

Tonal::Comma.ditonic => (531441/524288)

Returns:

  • (Rational)

    the comma found in the repo



36
37
38
# File 'lib/tonal/comma.rb', line 36

def self.method_missing(comma)
  commas[comma.to_s].to_r
end

.valuesArray

Returns of comma values.

Examples:

Tonal::Comma.values
=> [(2048/2025), (25/24), (648/625), ...]

Returns:

  • (Array)

    of comma values



19
20
21
# File 'lib/tonal/comma.rb', line 19

def self.values
  @values ||= commas.values.map(&:to_r)
end