Class: Textlint::Nodes::TxtNode
- Inherits:
-
Object
- Object
- Textlint::Nodes::TxtNode
- Defined in:
- lib/textlint/nodes.rb
Overview
export interface TxtNode
type: TxtNodeType;
raw: string;
range: TextNodeRange;
loc: TxtNodeLineLocation;
// parent is runtime information
// Not need in AST
// For example, top Root Node like `Document` has not parent.
parent?: TxtNode;
[index: string]: any;
Direct Known Subclasses
Instance Attribute Summary collapse
-
#loc ⇒ Object
readonly
Returns the value of attribute loc.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #as_textlint_json ⇒ Hash
-
#initialize(type:, raw:, range:, loc:) ⇒ TxtNode
constructor
A new instance of TxtNode.
Constructor Details
#initialize(type:, raw:, range:, loc:) ⇒ TxtNode
Returns a new instance of TxtNode.
105 106 107 108 109 110 |
# File 'lib/textlint/nodes.rb', line 105 def initialize(type:, raw:, range:, loc:) @type = type @raw = raw @range = range @loc = loc end |
Instance Attribute Details
#loc ⇒ Object (readonly)
Returns the value of attribute loc.
99 100 101 |
# File 'lib/textlint/nodes.rb', line 99 def loc @loc end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
99 100 101 |
# File 'lib/textlint/nodes.rb', line 99 def range @range end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
99 100 101 |
# File 'lib/textlint/nodes.rb', line 99 def raw @raw end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
99 100 101 |
# File 'lib/textlint/nodes.rb', line 99 def type @type end |
Instance Method Details
#as_textlint_json ⇒ Hash
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/textlint/nodes.rb', line 113 def as_textlint_json { type: type, raw: raw, range: [ range.begin, (range.exclude_end? ? range.end : range.end - 1) ], loc: loc.as_textlint_json } end |