Class: Rouge::RegexLexer::Rule

Inherits:
Object
  • Object
show all
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.

See Also:

  • StateDSL#rule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(re, callback) ⇒ Rule

Returns a new instance of Rule.



16
17
18
19
20
# File 'lib/rouge/regex_lexer.rb', line 16

def initialize(re, callback)
  @re = re
  @callback = callback
  @beginning_of_line = re.source[0] == ?^
end

Instance Attribute Details

#beginning_of_lineObject (readonly)

Returns the value of attribute beginning_of_line.



15
16
17
# File 'lib/rouge/regex_lexer.rb', line 15

def beginning_of_line
  @beginning_of_line
end

#callbackObject (readonly)

Returns the value of attribute callback.



13
14
15
# File 'lib/rouge/regex_lexer.rb', line 13

def callback
  @callback
end

#reObject (readonly)

Returns the value of attribute re.



14
15
16
# File 'lib/rouge/regex_lexer.rb', line 14

def re
  @re
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/rouge/regex_lexer.rb', line 22

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