Class: NanDoc::StreamColorizer::RegexRule

Inherits:
Object
  • Object
show all
Defined in:
lib/nandoc/support/stream-colorizer.rb

Direct Known Subclasses

RegexRuleNeg

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#regexObject (readonly)

Returns the value of attribute regex.



103
104
105
# File 'lib/nandoc/support/stream-colorizer.rb', line 103

def regex
  @regex
end

#stateObject (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