Class: Rouge::RegexLexer::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/rouge/lexer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(re, callback, next_state) ⇒ Rule

Returns a new instance of Rule.



187
188
189
190
191
# File 'lib/rouge/lexer.rb', line 187

def initialize(re, callback, next_state)
  @re = re
  @callback = callback
  @next_state = next_state
end

Instance Attribute Details

#callbackObject (readonly)

Returns the value of attribute callback.



184
185
186
# File 'lib/rouge/lexer.rb', line 184

def callback
  @callback
end

#next_stateObject (readonly)

Returns the value of attribute next_state.



185
186
187
# File 'lib/rouge/lexer.rb', line 185

def next_state
  @next_state
end

#reObject (readonly)

Returns the value of attribute re.



186
187
188
# File 'lib/rouge/lexer.rb', line 186

def re
  @re
end

Instance Method Details

#consume(stream, &b) ⇒ Object



197
198
199
200
201
202
203
204
205
206
# File 'lib/rouge/lexer.rb', line 197

def consume(stream, &b)
  stream.scan(@re)

  if stream.matched?
    yield stream
    return true
  end

  false
end

#inspectObject



193
194
195
# File 'lib/rouge/lexer.rb', line 193

def inspect
  "#<Rule #{@re.inspect}>"
end