Module: Musicality::Parseable::ClassMethods

Defined in:
lib/musicality/notation/parsing/parseable.rb

Instance Method Summary collapse

Instance Method Details

#parse(str) ⇒ Object

Raises:



12
13
14
15
16
17
18
# 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 = " ") ⇒ Object



20
21
22
# File 'lib/musicality/notation/parsing/parseable.rb', line 20

def split_parse str, pattern=" "
  str.split(pattern).map {|x| parse(x) }
end