Module: Leftovers::ProcessorBuilders::Transform
- Defined in:
- lib/leftovers/processor_builders/transform.rb
Class Method Summary collapse
-
.build(transform, arguments, then_processor) ⇒ Object
rubocop:disable Metrics.
Class Method Details
.build(transform, arguments, then_processor) ⇒ Object
rubocop:disable Metrics
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/leftovers/processor_builders/transform.rb', line 6 def self.build(transform, arguments, then_processor) # rubocop:disable Metrics case transform when :original, nil then then_processor when :downcase then Processors::Downcase.new(then_processor) when :upcase then Processors::Upcase.new(then_processor) when :capitalize then Processors::Capitalize.new(then_processor) when :swapcase then Processors::Swapcase.new(then_processor) when :pluralize then Processors::Pluralize.new(then_processor) when :singularize then Processors::Singularize.new(then_processor) when :camelize then Processors::Camelize.new(then_processor) when :titleize then Processors::Titleize.new(then_processor) when :demodulize then Processors::Demodulize.new(then_processor) when :deconstantize then Processors::Deconstantize.new(then_processor) when :parameterize then Processors::Parameterize.new(then_processor) when :underscore then Processors::Underscore.new(then_processor) when :transforms then TransformSet.build(arguments, then_processor) else Each.each_or_self(arguments) do |arg| case transform when :split then Processors::Split.new(arg, then_processor) when :delete_before then Processors::DeleteBefore.new(arg, then_processor) when :delete_before_last then Processors::DeleteBeforeLast.new(arg, then_processor) when :delete_after then Processors::DeleteAfter.new(arg, then_processor) when :delete_after_last then Processors::DeleteAfterLast.new(arg, then_processor) when :add_prefix then AddPrefix.build(arg, then_processor) when :add_suffix then AddSuffix.build(arg, then_processor) when :delete_prefix then Processors::DeletePrefix.new(arg, then_processor) when :delete_suffix then Processors::DeleteSuffix.new(arg, then_processor) # :nocov: else raise UnexpectedCase, "Unhandled value #{transform.to_s.inspect}" # :nocov: end end end end |