Class: Rouge::RegexLexer::Rule
- Inherits:
-
Object
- Object
- Rouge::RegexLexer::Rule
- Defined in:
- lib/rouge/regex_lexer.rb
Overview
A rule is a tuple of a regular expression to test, and a callback to perform if the test succeeds.
Instance Attribute Summary collapse
-
#beginning_of_line ⇒ Object
readonly
Returns the value of attribute beginning_of_line.
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#re ⇒ Object
readonly
Returns the value of attribute re.
Instance Method Summary collapse
-
#initialize(re, callback) ⇒ Rule
constructor
A new instance of Rule.
- #inspect ⇒ Object
Constructor Details
#initialize(re, callback) ⇒ Rule
Returns a new instance of Rule.
48 49 50 51 52 |
# File 'lib/rouge/regex_lexer.rb', line 48 def initialize(re, callback) @re = re @callback = callback @beginning_of_line = re.source[0] == ?^ end |
Instance Attribute Details
#beginning_of_line ⇒ Object (readonly)
Returns the value of attribute beginning_of_line.
47 48 49 |
# File 'lib/rouge/regex_lexer.rb', line 47 def beginning_of_line @beginning_of_line end |
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
45 46 47 |
# File 'lib/rouge/regex_lexer.rb', line 45 def callback @callback end |
#re ⇒ Object (readonly)
Returns the value of attribute re.
46 47 48 |
# File 'lib/rouge/regex_lexer.rb', line 46 def re @re end |
Instance Method Details
#inspect ⇒ Object
54 55 56 |
# File 'lib/rouge/regex_lexer.rb', line 54 def inspect "#<Rule #{@re.inspect}>" end |