Sha256: a3905c5700c37dde666ac844920a342e41383a41dba45751943a2a5749d63660

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

module XLSX
  class Cell # :nodoc:
    
    def self.type_of(value)
      return 's' if value.is_a? String
      return 'n' if value.is_a? Integer
      return 'n' if value.respond_to? :to_i
      return 's' if value.respond_to? :to_s
      return 's' # default
    end
    
    def self.storage_hash(row, column)
      Digest::SHA1.hexdigest("#{row}-#{column}")
    end
    
    attr_accessor :sheet, :type, :value, :row, :column
    
    def initialize(sheet, row, column)
      @sheet, @row, @column = sheet, row.to_i, column.to_i
    end
    
    def storage_hash
      @storage_hash ||= self.class.storage_hash(row, column)
    end
    
    def <=>(other)
      return(0) unless other.is_a?(::XLSX::Cell)
      order = (self.row    <=> other.row)
      order = (self.column <=> other.column) if order == 0
      order
    rescue
      0
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simonmenke-xlsx-0.0.1 lib/xlsx/cell.rb