Class: Ast::Merge::AstNode::Location

Inherits:
Struct
  • Object
show all
Defined in:
lib/ast/merge/ast_node.rb

Overview

Simple location struct for nodes that don’t have a native location object

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_columnObject

Returns the value of attribute end_column

Returns:

  • (Object)

    the current value of end_column



20
21
22
# File 'lib/ast/merge/ast_node.rb', line 20

def end_column
  @end_column
end

#end_lineObject

Returns the value of attribute end_line

Returns:

  • (Object)

    the current value of end_line



20
21
22
# File 'lib/ast/merge/ast_node.rb', line 20

def end_line
  @end_line
end

#start_columnObject

Returns the value of attribute start_column

Returns:

  • (Object)

    the current value of start_column



20
21
22
# File 'lib/ast/merge/ast_node.rb', line 20

def start_column
  @start_column
end

#start_lineObject

Returns the value of attribute start_line

Returns:

  • (Object)

    the current value of start_line



20
21
22
# File 'lib/ast/merge/ast_node.rb', line 20

def start_line
  @start_line
end

Instance Method Details

#cover?(line_number) ⇒ Boolean

Check if a line number falls within this location

Parameters:

  • line_number (Integer)

    The line number to check

Returns:

  • (Boolean)

    true if the line number is within the range



24
25
26
# File 'lib/ast/merge/ast_node.rb', line 24

def cover?(line_number)
  line_number >= start_line && line_number <= end_line
end