Class: Strling::Core::Esc

Inherits:
Node
  • Object
show all
Defined in:
lib/strling/core/nodes.rb

Overview

Represents a standalone escape sequence (e.g. d, w, s).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, property: nil) ⇒ Esc

Returns a new instance of Esc.

Parameters:

  • type (String)

    The escape type

  • property (String, nil) (defaults to: nil)

    The Unicode property name



193
194
195
196
# File 'lib/strling/core/nodes.rb', line 193

def initialize(type, property: nil)
  @type = type
  @property = property
end

Instance Attribute Details

#propertyString?

Returns The Unicode property name (for p and P).

Returns:

  • (String, nil)

    The Unicode property name (for p and P)



189
190
191
# File 'lib/strling/core/nodes.rb', line 189

def property
  @property
end

#typeString

Returns The escape type (d, D, w, W, s, S, p, P).

Returns:

  • (String)

    The escape type (d, D, w, W, s, S, p, P)



186
187
188
# File 'lib/strling/core/nodes.rb', line 186

def type
  @type
end

Instance Method Details

#to_dictObject



198
199
200
201
202
# File 'lib/strling/core/nodes.rb', line 198

def to_dict
  data = { 'kind' => 'Esc', 'type' => type }
  data['property'] = property if %w[p P].include?(type) && property
  data
end