Module: Writexlsx::Utility::Common

Constant Summary collapse

PERL_TRUE_VALUES =
[false, nil, 0, "0", "", [], {}].freeze

Instance Method Summary collapse

Instance Method Details

#absolute_char(absolute) ⇒ Object



25
26
27
# File 'lib/write_xlsx/utility/common.rb', line 25

def absolute_char(absolute)
  absolute ? '$' : ''
end

#check_parameter(params, valid_keys, method) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/write_xlsx/utility/common.rb', line 16

def check_parameter(params, valid_keys, method)
  invalids = params.keys - valid_keys
  unless invalids.empty?
    raise WriteXLSXOptionParameterError,
          "Unknown parameter '#{invalids.join(", ")}' in #{method}."
  end
  true
end

#float_to_str(float) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/write_xlsx/utility/common.rb', line 29

def float_to_str(float)
  return '' unless float

  if float == float.to_i
    float.to_i.to_s
  else
    float.to_s
  end
end

#ptrue?(value) ⇒ Boolean

return perl’s boolean result

Returns:

  • (Boolean)


12
13
14
# File 'lib/write_xlsx/utility/common.rb', line 12

def ptrue?(value)
  !PERL_TRUE_VALUES.include?(value)
end

#put_deprecate_message(method) ⇒ Object



39
40
41
# File 'lib/write_xlsx/utility/common.rb', line 39

def put_deprecate_message(method)
  warn("Warning: calling deprecated method #{method}. This method will be removed in a future release.")
end