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.



167
168
169
170
171
# File 'lib/rouge/lexer.rb', line 167

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.



164
165
166
# File 'lib/rouge/lexer.rb', line 164

def callback
  @callback
end

#next_stateObject (readonly)

Returns the value of attribute next_state.



165
166
167
# File 'lib/rouge/lexer.rb', line 165

def next_state
  @next_state
end

#reObject (readonly)

Returns the value of attribute re.



166
167
168
# File 'lib/rouge/lexer.rb', line 166

def re
  @re
end

Instance Method Details

#consume(stream, &b) ⇒ Object



177
178
179
180
181
182
183
184
185
186
# File 'lib/rouge/lexer.rb', line 177

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

  if stream.matched?
    yield stream
    return true
  end

  false
end

#inspectObject



173
174
175
# File 'lib/rouge/lexer.rb', line 173

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