Class: Ruby::Node::Position
- Includes:
- Comparable
- Defined in:
- lib/ruby/node/position.rb
Instance Attribute Summary collapse
-
#col ⇒ Object
Returns the value of attribute col.
-
#row ⇒ Object
Returns the value of attribute row.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #[](ix) ⇒ Object
-
#initialize(row, col) ⇒ Position
constructor
A new instance of Position.
- #inspect ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(row, col) ⇒ Position
Returns a new instance of Position.
8 9 10 11 |
# File 'lib/ruby/node/position.rb', line 8 def initialize(row, col) @row = row @col = col end |
Instance Attribute Details
#col ⇒ Object
Returns the value of attribute col.
6 7 8 |
# File 'lib/ruby/node/position.rb', line 6 def col @col end |
#row ⇒ Object
Returns the value of attribute row.
6 7 8 |
# File 'lib/ruby/node/position.rb', line 6 def row @row end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 |
# File 'lib/ruby/node/position.rb', line 17 def <=>(other) row < other.row ? -1 : row > other.row ? 1 : col <=> other.col end |
#==(other) ⇒ Object Also known as: eql?
21 22 23 |
# File 'lib/ruby/node/position.rb', line 21 def ==(other) to_a == other.to_a end |
#[](ix) ⇒ Object
13 14 15 |
# File 'lib/ruby/node/position.rb', line 13 def [](ix) ix == 0 ? row : col end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/ruby/node/position.rb', line 30 def inspect to_a.inspect end |
#to_a ⇒ Object
26 27 28 |
# File 'lib/ruby/node/position.rb', line 26 def to_a [row, col] end |