Module: ToSpreadsheet::TypeFromValue
- Included in:
- Rule::DefaultValue, Rule::Format
- Defined in:
- lib/to_spreadsheet/type_from_value.rb
Instance Method Summary collapse
Instance Method Details
#cell_type_from_value(v) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/to_spreadsheet/type_from_value.rb', line 3 def cell_type_from_value(v) if v.is_a?(Date) :date elsif v.is_a?(Time) :time elsif v.is_a?(TrueClass) || v.is_a?(FalseClass) :boolean elsif v.to_s.match(/\A[+-]?\d+?\Z/) #numeric :integer elsif v.to_s.match(/\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\Z/) #float :float else :string end end |