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.
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
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
164 165 166 |
# File 'lib/rouge/lexer.rb', line 164 def callback @callback end |
#next_state ⇒ Object (readonly)
Returns the value of attribute next_state.
165 166 167 |
# File 'lib/rouge/lexer.rb', line 165 def next_state @next_state end |
#re ⇒ Object (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 |
#inspect ⇒ Object
173 174 175 |
# File 'lib/rouge/lexer.rb', line 173 def inspect "#<Rule #{@re.inspect}>" end |