Class: Axlsx::Cell
- Inherits:
-
Object
- Object
- Axlsx::Cell
- Defined in:
- lib/barkest_core/extensions/axlsx_extenstions.rb
Overview
:nodoc:
Instance Method Summary collapse
- #barkest_core_original_cast_value ⇒ Object
-
#cast_value(v) ⇒ Object
Fix the conversion of Date/Time values.
Instance Method Details
#barkest_core_original_cast_value ⇒ Object
76 |
# File 'lib/barkest_core/extensions/axlsx_extenstions.rb', line 76 alias :barkest_core_original_cast_value :cast_value |
#cast_value(v) ⇒ Object
Fix the conversion of Date/Time values. :nodoc:
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/barkest_core/extensions/axlsx_extenstions.rb', line 80 def cast_value(v) return nil if v.nil? if @type == :date self.style = STYLE_DATE if self.style == 0 v elsif (@type == :time && v.is_a?(Time)) || (@type == :time && v.respond_to?(:to_time)) self.style = STYLE_DATE if self.style == 0 # one simple little fix. I DO NOT WANT TIME IN LOCAL TIME! unless v.is_a?(Time) v = v.respond_to?(:to_time) ? v.to_time : v end v elsif @type == :float v.to_f elsif @type == :integer v.to_i elsif @type == :boolean v ? 1 : 0 elsif @type == :iso_8601 #consumer is responsible for ensuring the iso_8601 format when specifying this type v else @type = :string # TODO find a better way to do this as it accounts for 30% of # processing time in benchmarking... Axlsx::trust_input ? v.to_s : ::CGI.escapeHTML(v.to_s) end end |