Class: RedQuilt::SourceSpan
- Inherits:
-
Object
- Object
- RedQuilt::SourceSpan
- Defined in:
- lib/red_quilt/source_span.rb
Instance Attribute Summary collapse
-
#end_byte ⇒ Object
readonly
Returns the value of attribute end_byte.
-
#start_byte ⇒ Object
readonly
Returns the value of attribute start_byte.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(start_byte, end_byte) ⇒ SourceSpan
constructor
A new instance of SourceSpan.
- #length ⇒ Object
- #to_h ⇒ Object
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_byte ⇒ Object (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_byte ⇒ Object (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 |
#length ⇒ Object
12 13 14 |
# File 'lib/red_quilt/source_span.rb', line 12 def length @end_byte - @start_byte end |
#to_h ⇒ Object
22 23 24 |
# File 'lib/red_quilt/source_span.rb', line 22 def to_h { start_byte: @start_byte, end_byte: @end_byte } end |