Class: TreeHaver::Base::Point
- Inherits:
-
Struct
- Object
- Struct
- TreeHaver::Base::Point
- Defined in:
- lib/tree_haver/base/point.rb
Overview
Point struct for position information (row/column)
Provides a consistent interface for 0-based row/column positions. Compatible with both hash-style access and method access.
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#row ⇒ Object
Returns the value of attribute row.
Instance Method Summary collapse
-
#[](key) ⇒ Integer?
Hash-style access for compatibility.
-
#inspect ⇒ String
Human-readable representation.
-
#to_h ⇒ Hash{Symbol => Integer}
Convert to hash.
-
#to_s ⇒ String
String representation.
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column
16 17 18 |
# File 'lib/tree_haver/base/point.rb', line 16 def column @column end |
#row ⇒ Object
Returns the value of attribute row
16 17 18 |
# File 'lib/tree_haver/base/point.rb', line 16 def row @row end |
Instance Method Details
#[](key) ⇒ Integer?
Hash-style access for compatibility
20 21 22 23 24 25 26 27 |
# File 'lib/tree_haver/base/point.rb', line 20 def [](key) case key when :row, "row", 0 row when :column, "column", 1 column end end |
#inspect ⇒ String
Human-readable representation
43 44 45 |
# File 'lib/tree_haver/base/point.rb', line 43 def inspect "#<TreeHaver::Base::Point row=#{row} column=#{column}>" end |
#to_h ⇒ Hash{Symbol => Integer}
Convert to hash
31 32 33 |
# File 'lib/tree_haver/base/point.rb', line 31 def to_h {row: row, column: column} end |
#to_s ⇒ String
String representation
37 38 39 |
# File 'lib/tree_haver/base/point.rb', line 37 def to_s "(#{row}, #{column})" end |