Class: CSVConverter::Converters::UppercaseConverter

Inherits:
BaseConverter
  • Object
show all
Defined in:
lib/csv_converter/converters/uppercase_converter.rb

Overview

Converts a string to uppercase

Instance Attribute Summary

Attributes inherited from BaseConverter

#options, #raw_data

Instance Method Summary collapse

Methods inherited from BaseConverter

#data, #empty_value?, #initialize

Constructor Details

This class inherits a constructor from CSVConverter::Converters::BaseConverter

Instance Method Details

#callString

Converts a string to uppercase

Returns:

  • (String)

    if data is empty returns an empty string.



9
10
11
12
13
# File 'lib/csv_converter/converters/uppercase_converter.rb', line 9

def call
  call!
rescue CSVConverter::Error
  nullable_object
end

#call!String

Converts a string to uppercase

Returns:

  • (String)

    if data is empty an error is raised.



17
18
19
20
21
22
23
# File 'lib/csv_converter/converters/uppercase_converter.rb', line 17

def call!
  raise ArgumentError, 'no data provided' if data.blank?

  data.upcase
rescue StandardError => e
  raise CSVConverter::Error.new(e.message, options)
end