Class: Strling::Core::ClassEscape
- Defined in:
- lib/strling/core/nodes.rb
Overview
Represents an escape sequence in a character class.
Matches predefined character classes (d, w, s, etc.) or Unicode property escapes (p…, P…).
Instance Attribute Summary collapse
-
#property ⇒ String?
The Unicode property name (for p and P).
-
#type ⇒ String
The escape type (d, D, w, W, s, S, p, P).
Instance Method Summary collapse
-
#initialize(type, property: nil) ⇒ ClassEscape
constructor
A new instance of ClassEscape.
- #to_dict ⇒ Object
Constructor Details
#initialize(type, property: nil) ⇒ ClassEscape
Returns a new instance of ClassEscape.
268 269 270 271 |
# File 'lib/strling/core/nodes.rb', line 268 def initialize(type, property: nil) @type = type @property = property end |
Instance Attribute Details
#property ⇒ String?
Returns The Unicode property name (for p and P).
264 265 266 |
# File 'lib/strling/core/nodes.rb', line 264 def property @property end |
#type ⇒ String
Returns The escape type (d, D, w, W, s, S, p, P).
261 262 263 |
# File 'lib/strling/core/nodes.rb', line 261 def type @type end |
Instance Method Details
#to_dict ⇒ Object
273 274 275 276 277 |
# File 'lib/strling/core/nodes.rb', line 273 def to_dict data = { 'kind' => 'Esc', 'type' => type } data['property'] = property if %w[p P].include?(type) && property data end |