Class: SyntaxTree::SingleByteString
- Inherits:
-
Object
- Object
- SyntaxTree::SingleByteString
- Defined in:
- lib/syntax_tree.rb
Overview
Represents a line in the source. If this class is being used, it means that every character in the string is 1 byte in length, so we can just return the start of the line + the index.
Instance Attribute Summary collapse
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #[](byteindex) ⇒ Object
-
#initialize(start) ⇒ SingleByteString
constructor
A new instance of SingleByteString.
Constructor Details
#initialize(start) ⇒ SingleByteString
Returns a new instance of SingleByteString.
31 32 33 |
# File 'lib/syntax_tree.rb', line 31 def initialize(start) @start = start end |
Instance Attribute Details
#start ⇒ Object (readonly)
Returns the value of attribute start.
29 30 31 |
# File 'lib/syntax_tree.rb', line 29 def start @start end |
Instance Method Details
#[](byteindex) ⇒ Object
35 36 37 |
# File 'lib/syntax_tree.rb', line 35 def [](byteindex) start + byteindex end |