Class: TreeHaver::Point
- Inherits:
-
Object
- Object
- TreeHaver::Point
- Defined in:
- lib/tree_haver/node.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) ⇒ Object
Hash-like access for compatibility.
-
#initialize(row, column) ⇒ Point
constructor
A new instance of Point.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(row, column) ⇒ Point
Returns a new instance of Point.
12 13 14 15 |
# File 'lib/tree_haver/node.rb', line 12 def initialize(row, column) @row = row @column = column end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
10 11 12 |
# File 'lib/tree_haver/node.rb', line 10 def column @column end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
10 11 12 |
# File 'lib/tree_haver/node.rb', line 10 def row @row end |
Instance Method Details
#[](key) ⇒ Object
Hash-like access for compatibility
18 19 20 21 22 23 |
# File 'lib/tree_haver/node.rb', line 18 def [](key) case key when :row, "row" then @row when :column, "column" then @column end end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/tree_haver/node.rb', line 33 def inspect "#<TreeHaver::Point row=#{@row} column=#{@column}>" end |
#to_h ⇒ Object
25 26 27 |
# File 'lib/tree_haver/node.rb', line 25 def to_h {row: @row, column: @column} end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/tree_haver/node.rb', line 29 def to_s "(#{@row}, #{@column})" end |