Class: Rouge::RegexLexer::Rule
- Inherits:
-
Object
- Object
- Rouge::RegexLexer::Rule
- Defined in:
- lib/rouge/lexer.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#next_state ⇒ Object
readonly
Returns the value of attribute next_state.
-
#re ⇒ Object
readonly
Returns the value of attribute re.
Instance Method Summary collapse
- #consume(stream, &b) ⇒ Object
-
#initialize(re, callback, next_state) ⇒ Rule
constructor
A new instance of Rule.
- #inspect ⇒ Object
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
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
184 185 186 |
# File 'lib/rouge/lexer.rb', line 184 def callback @callback end |
#next_state ⇒ Object (readonly)
Returns the value of attribute next_state.
185 186 187 |
# File 'lib/rouge/lexer.rb', line 185 def next_state @next_state end |
#re ⇒ Object (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 |
#inspect ⇒ Object
193 194 195 |
# File 'lib/rouge/lexer.rb', line 193 def inspect "#<Rule #{@re.inspect}>" end |