Sha256: d3467f91032dbe705e92f18859eb8409a1cda3ba3848b4c028850a7152710f55

Contents?: true

Size: 953 Bytes

Versions: 2

Compression:

Stored size: 953 Bytes

Contents

module CurriculumGenerator
  module Generator
    class CvItemWithComment < BasicGenerator

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

      def generate
        value = get_value(param)
        value = Array[value] unless value.is_a?(Array)

        inst = self
        value.collect do |elem|
          result = Either.chain do
            bind -> { elem.is_a?(Hash) }
            bind -> {
              elem.has_key?('title') &&
                  elem.has_key?('content') &&
                  elem.has_key?('comment')
            }
            bind -> {
              inst.get_cv_item_with_comment(elem['title'], elem['content'], elem['comment'])
            }
          end
          result.success? ? result.fetch : ''
        end.join("\n")
      end

      def get_cv_item_with_comment(title, content, comment)
        "\\cvitemwithcomment{#{title}}{#{content}}{#{comment}}"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curriculum-generator-1.0.7 lib/curriculum-generator/generator/cv_item_with_comment.rb
curriculum-generator-1.0.6 lib/curriculum-generator/generator/cv_item_with_comment.rb