Class: JSON5::Node
- Inherits:
-
Object
- Object
- JSON5::Node
- Defined in:
- lib/json5/document_nodes.rb
Direct Known Subclasses
ArrayNode, IdentifierNameNode, LiteralNode, MemberNode, NumberNode, ObjectNode, StringNode
Instance Attribute Summary collapse
-
#end_byte ⇒ Object
readonly
Returns the value of attribute end_byte.
-
#leading_trivia ⇒ Object
readonly
Returns the value of attribute leading_trivia.
-
#raw_span ⇒ Object
readonly
Returns the value of attribute raw_span.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#start_byte ⇒ Object
readonly
Returns the value of attribute start_byte.
-
#trailing_trivia ⇒ Object
readonly
Returns the value of attribute trailing_trivia.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, source:, start_byte:, end_byte:, leading_trivia: [], trailing_trivia: []) ⇒ Node
constructor
A new instance of Node.
- #raw ⇒ Object
Constructor Details
#initialize(type:, source:, start_byte:, end_byte:, leading_trivia: [], trailing_trivia: []) ⇒ Node
Returns a new instance of Node.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/json5/document_nodes.rb', line 9 def initialize(type:, source:, start_byte:, end_byte:, leading_trivia: [], trailing_trivia: []) @type = type.to_sym @source = source @start_byte = start_byte @end_byte = end_byte @raw_span = ByteSpan.new(start_byte, end_byte) @leading_trivia = leading_trivia.dup.freeze @trailing_trivia = trailing_trivia.dup.freeze freeze end |
Instance Attribute Details
#end_byte ⇒ Object (readonly)
Returns the value of attribute end_byte.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def end_byte @end_byte end |
#leading_trivia ⇒ Object (readonly)
Returns the value of attribute leading_trivia.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def leading_trivia @leading_trivia end |
#raw_span ⇒ Object (readonly)
Returns the value of attribute raw_span.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def raw_span @raw_span end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def source @source end |
#start_byte ⇒ Object (readonly)
Returns the value of attribute start_byte.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def start_byte @start_byte end |
#trailing_trivia ⇒ Object (readonly)
Returns the value of attribute trailing_trivia.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def trailing_trivia @trailing_trivia end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/json5/document_nodes.rb', line 7 def type @type end |
Instance Method Details
#raw ⇒ Object
20 21 22 |
# File 'lib/json5/document_nodes.rb', line 20 def raw source.byteslice(start_byte...end_byte) end |