Class: Rouge::RegexLexer::State
- Inherits:
-
Object
- Object
- Rouge::RegexLexer::State
- Defined in:
- lib/rouge/lexer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(lexer_class, name, &defn) ⇒ State
constructor
A new instance of State.
- #load! ⇒ Object
- #relative_state(state_name = nil, &b) ⇒ Object
- #rules ⇒ Object
Constructor Details
#initialize(lexer_class, name, &defn) ⇒ State
Returns a new instance of State.
191 192 193 194 195 |
# File 'lib/rouge/lexer.rb', line 191 def initialize(lexer_class, name, &defn) @lexer_class = lexer_class @name = name @defn = defn end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
190 191 192 |
# File 'lib/rouge/lexer.rb', line 190 def name @name end |
Instance Method Details
#load! ⇒ Object
209 210 211 212 213 214 |
# File 'lib/rouge/lexer.rb', line 209 def load! return self if @loaded @loaded = true StateDSL.new(rules).instance_eval(&@defn) self end |
#relative_state(state_name = nil, &b) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/rouge/lexer.rb', line 197 def relative_state(state_name=nil, &b) if state_name @lexer_class.get_state(state_name) else State.new(@lexer_class, b.inspect, &b).load! end end |
#rules ⇒ Object
205 206 207 |
# File 'lib/rouge/lexer.rb', line 205 def rules @rules ||= [] end |