Sha256: 3f50d33e9fe63fe73a2426802ae0f5c4feaa9d6b0f3f206c673e9bf9f6886b5c

Contents?: true

Size: 531 Bytes

Versions: 10

Compression:

Stored size: 531 Bytes

Contents

module HeadMusic
  module NamedRudiment
    attr_reader :name
    delegate :to_s, to: :name

    def initialize(name)
      @name = name.to_s
    end

    def hash_key
      HeadMusic::Utilities::HashKey.for(name)
    end

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def get_by_name(name)
        name = name.to_s
        @instances_by_name ||= {}
        key = HeadMusic::Utilities::HashKey.for(name)
        @instances_by_name[key] ||= new(name)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
head_music-0.17.0 lib/head_music/named_rudiment.rb
head_music-0.16.2 lib/head_music/named_rudiment.rb
head_music-0.16.0 lib/head_music/named_rudiment.rb
head_music-0.14.8 lib/head_music/named_rudiment.rb
head_music-0.14.7 lib/head_music/named_rudiment.rb
head_music-0.14.5 lib/head_music/named_rudiment.rb
head_music-0.14.4 lib/head_music/named_rudiment.rb
head_music-0.14.2 lib/head_music/named_rudiment.rb
head_music-0.14.1 lib/head_music/named_rudiment.rb
head_music-0.13.2 lib/head_music/named_rudiment.rb