Sha256: 66159eb2b23d14ba9fd8ff1b527dd32f451acbb24b44bc69512a0ef0296470b9

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

module CurriculumGenerator
  module Generator
    class CvDoubleItem < BasicGenerator

      def initialize(param, data, lang)
        super(param, data, lang)
      end

      def generate
        value = get_value(param)
        unless value.is_a?(Array)
          value = Array[value]
        end
        value.collect do |elem|
          instance = self
          result = Either.chain do
            bind -> { elem.is_a?(Hash) }
            bind -> {
              elem.has_key?('item_0') &&
                  elem['item_0'].has_key?('title') &&
                  elem['item_0'].has_key?('content')
            }
            bind -> {
              elem.has_key?('item_1') &&
                  elem['item_1'].has_key?('title') &&
                  elem['item_1'].has_key?('content')
            }
            bind -> {
              instance.get_cv_double_item(elem['item_0'], elem['item_1'])
            }
          end
          result.success? ? result.fetch : ''
        end.join("\n")
      end

      protected

      def get_cv_double_item(item_0, item_1)
        "\\cvdoubleitem" +
            "{#{item_0['title']}}{#{item_0['content']}}" +
            "{#{item_1['title']}}{#{item_1['content']}}"
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curriculum-generator-1.0.7 lib/curriculum-generator/generator/cv_double_item.rb
curriculum-generator-1.0.6 lib/curriculum-generator/generator/cv_double_item.rb
curriculum-generator-1.0.5 lib/curriculum-generator/generator/cv_double_item.rb