From e93c80febf757290fecce6eebce871c2448dad14 Mon Sep 17 00:00:00 2001 From: Steven Daniels Date: Sat, 31 Dec 2016 13:08:05 -0500 Subject: [PATCH] Refactoring some classes to reduce complexity --- lib/roo/excelx.rb | 2 +- lib/roo/excelx/cell/datetime.rb | 66 +++++++++++++++++++-------------- lib/roo/excelx/cell/number.rb | 41 +++++++++----------- lib/roo/excelx/cell/time.rb | 26 ++++++------- 4 files changed, 70 insertions(+), 65 deletions(-) diff --git a/lib/roo/excelx.rb b/lib/roo/excelx.rb index 2126af74..82c14314 100644 --- a/lib/roo/excelx.rb +++ b/lib/roo/excelx.rb @@ -223,7 +223,7 @@ def empty?(row, col, sheet = nil) sheet = sheet_for(sheet) key = normalize(row, col) cell = sheet.cells[key] - !cell || cell.empty? || (cell.type == :string && cell.value.empty?) || + !cell || cell.empty? || (row < sheet.first_row || row > sheet.last_row || col < sheet.first_column || col > sheet.last_column) end diff --git a/lib/roo/excelx/cell/datetime.rb b/lib/roo/excelx/cell/datetime.rb index 0bd62ca0..35d93ac8 100644 --- a/lib/roo/excelx/cell/datetime.rb +++ b/lib/roo/excelx/cell/datetime.rb @@ -32,14 +32,9 @@ def initialize(value, formula, excelx_type, style, link, base_date, coordinate) # # Returns a String representation of a cell's value. def formatted_value - date_regex = /(?[dmy]+[\-\/][dmy]+([\-\/][dmy]+)?)/ - time_regex = /(?