Module: MusicIds::Id::ClassMethods

Defined in:
lib/music_ids/id.rb

Instance Method Summary collapse

Instance Method Details

#parse(input, opts = {}) ⇒ ISRC

Parse an identifier string into an instance

Parameters:

  • input (String) —

    The input identifier string to parse

  • opts (Hash) (defaults to: {}) —

    Parsing options

Options Hash (opts):

  • :relaxed (true, false) — default: false —

    Whether to parse in relaxed mode

Returns:

  • (ISRC) —

    the ISRC instance



10
11
12
# File 'lib/music_ids/id.rb', line 10

def parse(input, opts = {})
  opts[:relaxed] ? relaxed(input) : parse_strict(input)
end

#relaxed(input) ⇒ Object



14
15
16
17
18
# File 'lib/music_ids/id.rb', line 14

def relaxed(input)
  parse_string(input) { |input|
    new(input, ok: false) unless input.nil?
  }
end