Class: Version::RegexParser Private

Inherits:
Parser
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
brew/Library/Homebrew/version/parser.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

StemParser, UrlParser

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex, &block) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • regex (Regexp)
  • block (T.proc.params(arg0: String).returns(String), nil)


22
23
24
25
26
# File 'brew/Library/Homebrew/version/parser.rb', line 22

def initialize(regex, &block)
  super()
  @regex = regex
  @block = block
end

Class Method Details

.process_spec(spec) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.

Parameters:

Returns:



41
# File 'brew/Library/Homebrew/version/parser.rb', line 41

def self.process_spec(spec); end

Instance Method Details

#parse(spec) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:



29
30
31
32
33
34
35
36
37
38
# File 'brew/Library/Homebrew/version/parser.rb', line 29

def parse(spec)
  match = @regex.match(self.class.process_spec(spec))
  return if match.blank?

  version = match.captures.first
  return if version.blank?
  return @block.call(version) if @block.present?

  version
end