Class: UserChoices::SplittingConversion

Inherits:
Conversion
  • Object
show all
Defined in:
lib/user-choices/conversions.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Conversion

#does_length_check?, for, inherited, #initialize, is_abstract, record_for

Constructor Details

This class inherits a constructor from UserChoices::Conversion

Class Method Details

.described_by?(conversion_tag) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/user-choices/conversions.rb', line 88

def self.described_by?(conversion_tag)
  conversion_tag == [:string]
end

Instance Method Details

#convert(value) ⇒ Object



98
99
100
101
102
103
# File 'lib/user-choices/conversions.rb', line 98

def convert(value)
  case value
  when String then value.split(',')
  when Array then value
  end
end

#descriptionObject



92
# File 'lib/user-choices/conversions.rb', line 92

def description; "a comma-separated list"; end

#suitable?(actual) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/user-choices/conversions.rb', line 94

def suitable?(actual)
  actual.is_a?(String) || actual.is_a?(Array)
end