Module: NanDoc::RegexpEnhance
- Defined in:
- lib/nandoc/support/regexp-enhance.rb
Defined Under Namespace
Modules: MatchData
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.names(re, *list) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/nandoc/support/regexp-enhance.rb', line 14 def names re, *list to(re) do |re| re.names(*list) end nil end |
.to(re, &block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/nandoc/support/regexp-enhance.rb', line 20 def to re, &block re.extend(self) re.regexp_enhance_init block.call(re) nil end |
Instance Method Details
#match_assert(str, name = nil) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/nandoc/support/regexp-enhance.rb', line 38 def match_assert str, name=nil match(str) or begin use_name = name || "/#{source}/" fail("#{use_name} failed to match #{str.inspect}") end end |
#names(*list) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/nandoc/support/regexp-enhance.rb', line 44 def names *list if list.any? @names = list else @names end end |