Sha256: cea29b5bed1794937a9414f65800882ff151f74ec2fce59b2eca4f9313c54d12
Contents?: true
Size: 656 Bytes
Versions: 4
Compression:
Stored size: 656 Bytes
Contents
module ExcelAbstraction class CellReference include Comparable COLS = ('A'..'ZZ').to_a attr_accessor :row, :col def initialize(attrs = {}) @row = attrs.fetch(:row) { 0 } @col = attrs.fetch(:col) { 0 } end def <=>(other) other = other.to_cell_reference (self.row == other.row) ? (self.col <=> other.col) : (self.row <=> other.row) end def succ self.class.new(row: self.row, col: self.col + 1) end def to_s COLS[col] + (row + 1).to_s end def to_cell_reference self end def to_ary [row, col] end def to_a to_ary end end end
Version data entries
4 entries across 4 versions & 1 rubygems