Class: SyntaxTree::SingleByteString

Inherits:
Object
  • Object
show all
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 Method Summary collapse

Constructor Details

#initialize(start) ⇒ SingleByteString

Returns a new instance of SingleByteString.



29
30
31
# File 'lib/syntax_tree.rb', line 29

def initialize(start)
  @start = start
end

Instance Method Details

#[](byteindex) ⇒ Object



33
34
35
# File 'lib/syntax_tree.rb', line 33

def [](byteindex)
  @start + byteindex
end