Class: Ast::Merge::AstNode::Point

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

Overview

Point class compatible with TreeHaver::Point Provides both method and hash-style access to row/column

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnObject

Returns the value of attribute column

Returns:

  • (Object)

    the current value of column



47
48
49
# File 'lib/ast/merge/ast_node.rb', line 47

def column
  @column
end

#rowObject

Returns the value of attribute row

Returns:

  • (Object)

    the current value of row



47
48
49
# File 'lib/ast/merge/ast_node.rb', line 47

def row
  @row
end

Instance Method Details

#[](key) ⇒ Object

Hash-like access for compatibility



49
50
51
52
53
54
# File 'lib/ast/merge/ast_node.rb', line 49

def [](key)
  case key
  when :row, 'row' then row
  when :column, 'column' then column
  end
end

#inspectString

Return a debug-oriented representation of the point.

Returns:

  • (String)


73
74
75
# File 'lib/ast/merge/ast_node.rb', line 73

def inspect
  "#<Ast::Merge::AstNode::Point row=#{row} column=#{column}>"
end

#to_hHash{Symbol => Integer, nil}

Return the point as a Hash.

Returns:

  • (Hash{Symbol => Integer, nil})

    row/column pair



59
60
61
# File 'lib/ast/merge/ast_node.rb', line 59

def to_h
  { row: row, column: column }
end

#to_sString

Return a compact human-readable point representation.

Returns:

  • (String)


66
67
68
# File 'lib/ast/merge/ast_node.rb', line 66

def to_s
  "(#{row}, #{column})"
end