Class: TreeHaver::Point
- Inherits:
-
Object
- Object
- TreeHaver::Point
- Defined in:
- lib/tree_haver/point.rb
Overview
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
-
#[](key) ⇒ Integer?
Hash-like access for compatibility.
-
#initialize(row, column) ⇒ Point
constructor
Create a new Point.
-
#inspect ⇒ String
Inspect representation.
-
#to_h ⇒ Hash{Symbol => Integer}
Convert to a hash.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(row, column) ⇒ Point
Create a new Point
28 29 30 31 |
# File 'lib/tree_haver/point.rb', line 28 def initialize(row, column) @row = row @column = column end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
22 23 24 |
# File 'lib/tree_haver/point.rb', line 22 def column @column end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
22 23 24 |
# File 'lib/tree_haver/point.rb', line 22 def row @row end |
Instance Method Details
#[](key) ⇒ Integer?
Hash-like access for compatibility
37 38 39 40 41 42 |
# File 'lib/tree_haver/point.rb', line 37 def [](key) case key when :row, "row" then @row when :column, "column" then @column end end |
#inspect ⇒ String
Inspect representation
61 62 63 |
# File 'lib/tree_haver/point.rb', line 61 def inspect "#<TreeHaver::Point row=#{@row} column=#{@column}>" end |
#to_h ⇒ Hash{Symbol => Integer}
Convert to a hash
47 48 49 |
# File 'lib/tree_haver/point.rb', line 47 def to_h {row: @row, column: @column} end |
#to_s ⇒ String
String representation
54 55 56 |
# File 'lib/tree_haver/point.rb', line 54 def to_s "(#{@row}, #{@column})" end |