Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/pathfinding/core/node.rb
Overview
Represents a node in the grid.
Instance Attribute Summary collapse
-
#walkable ⇒ Object
readonly
Gets whether the node is walkable.
-
#x ⇒ Object
readonly
Gets the x coordinate in the grid.
-
#y ⇒ Object
readonly
Gets the y coordinate in the grid.
Instance Method Summary collapse
-
#initialize(x, y, walkable = true) ⇒ Node
constructor
Creates a node.
-
#to_s ⇒ Object
Makes the string format of a node.
Constructor Details
#initialize(x, y, walkable = true) ⇒ Node
Creates a node.
25 26 27 28 29 |
# File 'lib/pathfinding/core/node.rb', line 25 def initialize(x, y, walkable = true) @x = x @y = y @walkable = walkable end |
Instance Attribute Details
#walkable ⇒ Object (readonly)
Gets whether the node is walkable.
20 21 22 |
# File 'lib/pathfinding/core/node.rb', line 20 def walkable @walkable end |
#x ⇒ Object (readonly)
Gets the x coordinate in the grid.
14 15 16 |
# File 'lib/pathfinding/core/node.rb', line 14 def x @x end |
#y ⇒ Object (readonly)
Gets the y coordinate in the grid.
17 18 19 |
# File 'lib/pathfinding/core/node.rb', line 17 def y @y end |
Instance Method Details
#to_s ⇒ Object
Makes the string format of a node.
34 35 36 |
# File 'lib/pathfinding/core/node.rb', line 34 def to_s "(#{@x}, #{@y})" end |