module Musicality::Parseable::ClassMethods

Public Instance Methods

parse(str) click to toggle source
# File lib/musicality/notation/parsing/parseable.rb, line 12
def parse str
  parser = self.const_get(:PARSER)
  node = parser.parse(str)
  raise ParseError, "Failed to parse #{str}" if node.nil?

  node.send(self.const_get(:CONVERSION_METHOD))
end
split_parse(str, pattern=" ") click to toggle source
# File lib/musicality/notation/parsing/parseable.rb, line 20
def split_parse str, pattern=" "
  str.split(pattern).map {|x| parse(x) }
end