Class: SyntaxTree::Parser::SingleByteString

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/parser.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

Instance Method Summary collapse

Constructor Details

#initialize(start) ⇒ SingleByteString

Returns a new instance of SingleByteString.



23
24
25
# File 'lib/syntax_tree/parser.rb', line 23

def initialize(start)
  @start = start
end

Instance Attribute Details

#startObject (readonly)

Returns the value of attribute start.



21
22
23
# File 'lib/syntax_tree/parser.rb', line 21

def start
  @start
end

Instance Method Details

#[](byteindex) ⇒ Object



27
28
29
# File 'lib/syntax_tree/parser.rb', line 27

def [](byteindex)
  start + byteindex
end