diff options
| author | Runar Ingebrigtsen <[email protected]> | 2015-11-18 14:21:58 +0100 |
|---|---|---|
| committer | Runar Ingebrigtsen <[email protected]> | 2015-11-18 14:21:58 +0100 |
| commit | ec5ab8a5a624f2bcb2f341a219279d8d4264150d (patch) | |
| tree | bbeb6d347b4fb7a21dcfc980cacbfca8ff0899b5 /lib | |
| parent | e977cf5232273fa45734cdb36f6fae4db2cbe781 (diff) | |
| download | caxlsx-ec5ab8a5a624f2bcb2f341a219279d8d4264150d.tar.gz caxlsx-ec5ab8a5a624f2bcb2f341a219279d8d4264150d.zip | |
remove some code reek
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 3136d0e0..cd832f7b 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -37,14 +37,14 @@ module Axlsx # to get less GC cycles type = options.delete(:type) || cell_type_from_value(value) self.type = type unless type == :string - + val = options.delete(:style) self.style = val unless val.nil? || val == 0 val = options.delete(:formula_value) self.formula_value = val unless val.nil? - - parse_options(options) + + parse_options(options) self.value = value value.cell = self if contains_rich_text? @@ -64,7 +64,7 @@ module Axlsx :family, :b, :i, :strike, :outline, :shadow, :condense, :extend, :u, :vertAlign, :sz, :color, :scheme].freeze - + CELL_TYPES = [:date, :time, :float, :integer, :richtext, :string, :boolean, :iso_8601].freeze @@ -93,7 +93,7 @@ module Axlsx def type defined?(@type) ? @type : :string end - + # @see type def type=(v) RestrictionValidator.validate :cell_type, CELL_TYPES, v @@ -104,7 +104,7 @@ module Axlsx # The value of this cell. # @return [String, Integer, Float, Time, Boolean] casted value based on cell's type attribute. attr_reader :value - + # @see value def value=(v) #TODO: consider doing value based type determination first? @@ -115,12 +115,12 @@ module Axlsx # @return [Boolean] def is_text_run? defined?(@is_text_run) && @is_text_run && !contains_rich_text? - end - + end + def contains_rich_text? type == :richtext end - + # Indicates if the cell is good for shared string table def plain_string? type == :string && # String typed @@ -347,7 +347,7 @@ module Axlsx # returns the name of the cell attr_reader :name - + def autowidth return if is_formula? || value.nil? if contains_rich_text? @@ -363,7 +363,7 @@ module Axlsx string_width(value, font_size) end end - + # Returns the sanatized value # TODO find a better way to do this as it accounts for 30% of # processing time in benchmarking... @@ -376,17 +376,17 @@ module Axlsx end private - + def styles row.worksheet.styles end - + # Returns the width of a string according to the current style # This is still not perfect... # - scaling is not linear as font sizes increase def string_width(string, font_size) font_scale = font_size / 10.0 - (string.to_s.count(Worksheet::THIN_CHARS) + 3.0) * (font_size/10.0) + (string.to_s.count(Worksheet::THIN_CHARS) + 3.0) * font_scale end # we scale the font size if bold style is applied to either the style font or |
