Class: Lab42::Rgxargs::Syntax

Inherits:
Object
  • Object
show all
Defined in:
lib/lab42/rgxargs/syntax.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#converterObject (readonly)

Returns the value of attribute converter.



3
4
5
# File 'lib/lab42/rgxargs/syntax.rb', line 3

def converter
  @converter
end

#matcherObject (readonly)

Returns the value of attribute matcher.



3
4
5
# File 'lib/lab42/rgxargs/syntax.rb', line 3

def matcher
  @matcher
end

Instance Method Details

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'lib/lab42/rgxargs/syntax.rb', line 5

def matches? value
  if match = matcher.match(value)
    yield converter.(*match.captures)
    true
  end
end