Sha256: 22bc22fb60977f12d5c5c2e22473f1f83c0e5d7a91464af099134d6ae0eb1937

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

module Music
module Transcription

# to use, include Parseable and define PARSER constant that has #parse method.
module Parseable
  DEFAULT_SPLIT_PATTERN = " "
  
  def self.included(base)
    base.extend(ClassMethods)
  end
  
  module ClassMethods
    def parser
      self.const_get(:PARSER)
    end
    
    def convert node
      node.send(self.const_get(:CONVERSION_METHOD))
    end
    
    def parse str
      convert(parser.parse(str))
    end
    
    def split_parse str, pattern=" "
      str.split(pattern).map {|x| convert(parser.parse(x)) }
    end  
  end  
end  

end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
music-transcription-0.21.0 lib/music-transcription/parsing/parseable.rb
music-transcription-0.20.0 lib/music-transcription/parsing/parseable.rb
music-transcription-0.19.0 lib/music-transcription/parsing/parseable.rb