Class: RedQuilt::SourceSpan

Inherits:
Object
  • Object
show all
Defined in:
lib/red_quilt/source_span.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_byte, end_byte) ⇒ SourceSpan

Returns a new instance of SourceSpan.



7
8
9
10
# File 'lib/red_quilt/source_span.rb', line 7

def initialize(start_byte, end_byte)
  @start_byte = start_byte
  @end_byte = end_byte
end

Instance Attribute Details

#end_byteObject (readonly)

Returns the value of attribute end_byte.



5
6
7
# File 'lib/red_quilt/source_span.rb', line 5

def end_byte
  @end_byte
end

#start_byteObject (readonly)

Returns the value of attribute start_byte.



5
6
7
# File 'lib/red_quilt/source_span.rb', line 5

def start_byte
  @start_byte
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
20
# File 'lib/red_quilt/source_span.rb', line 16

def ==(other)
  other.is_a?(SourceSpan) &&
    other.start_byte == @start_byte &&
    other.end_byte == @end_byte
end

#lengthObject



12
13
14
# File 'lib/red_quilt/source_span.rb', line 12

def length
  @end_byte - @start_byte
end

#to_hObject



22
23
24
# File 'lib/red_quilt/source_span.rb', line 22

def to_h
  { start_byte: @start_byte, end_byte: @end_byte }
end