Class: NanDoc::StreamColorizer::RegexRule
- Inherits:
-
Object
- Object
- NanDoc::StreamColorizer::RegexRule
- Defined in:
- lib/nandoc/support/stream-colorizer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(regex, state) ⇒ RegexRule
constructor
A new instance of RegexRule.
- #match(str) ⇒ Object
Constructor Details
#initialize(regex, state) ⇒ RegexRule
Returns a new instance of RegexRule.
99 100 101 102 |
# File 'lib/nandoc/support/stream-colorizer.rb', line 99 def initialize regex, state @regex = regex @state = state or fail('no') end |
Instance Attribute Details
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
103 104 105 |
# File 'lib/nandoc/support/stream-colorizer.rb', line 103 def regex @regex end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
103 104 105 |
# File 'lib/nandoc/support/stream-colorizer.rb', line 103 def state @state end |
Class Method Details
.make(regex, state, opts) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/nandoc/support/stream-colorizer.rb', line 91 def make regex, state, opts if opts[:neg] RegexRuleNeg.new(regex, state) else RegexRule.new(regex, state) end end |
Instance Method Details
#match(str) ⇒ Object
104 105 106 |
# File 'lib/nandoc/support/stream-colorizer.rb', line 104 def match str @regex =~ str end |