Sha256: a6852d48cb846ae824280f0bc9d4f53fd26a4a19bad62613c3628f282f30d7f8

Contents?: true

Size: 1.46 KB

Versions: 35

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

module Quby
  module AnswersHelper
    def get_validation_json(validations)
      result = {}
      validations.each_pair do |qkey, valar|
        result[qkey] = valar.map do |val|
          if val[:type] == :regexp
            valc = val.clone
            valc[:matcher] = valc[:matcher].source.to_s
            # Replace single backslashes with two backslashes
            valc[:matcher].gsub!("\\", "\\\\")
            valc
          else
            val
          end
        end
      end
      result.to_json
    end

    def different_header(item, previous_item)
      return true unless item.score_header == previous_item&.score_header && previous_item.respond_to?(:options)
      case item.score_header
      when :question_description
        return item.description != previous_item.description
      when :value
        return previous_item.options.map(&:value) != item.options.map(&:value)
      when :description
        return previous_item.options.map(&:description) != item.options.map(&:description)
      end
    end

    def get_question(table, rowi, j)
      q = get_item(table, rowi, j)
      q.is_a?(Quby::Questionnaires::Entities::Question) ? q : nil
    end

    def get_item(table, rowi, j)
      table.item_table[rowi][j]
    end

    def light_dark_for(cyclei, same_question)
      if same_question
        return ""
      elsif cyclei.modulo(2) == 0
        return "light"
      else
        return "dark"
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
quby-5.6.7 app/helpers/quby/answers_helper.rb
quby-5.6.6 app/helpers/quby/answers_helper.rb
quby-5.6.5 app/helpers/quby/answers_helper.rb
quby-5.6.3 app/helpers/quby/answers_helper.rb
quby-5.6.2 app/helpers/quby/answers_helper.rb
quby-5.6.1 app/helpers/quby/answers_helper.rb
quby-5.6.0 app/helpers/quby/answers_helper.rb
quby-5.5.0 app/helpers/quby/answers_helper.rb
quby-5.4.0 app/helpers/quby/answers_helper.rb
quby-5.3.1 app/helpers/quby/answers_helper.rb
quby-5.3.0 app/helpers/quby/answers_helper.rb
quby-5.2.0 app/helpers/quby/answers_helper.rb
quby-5.1.3 app/helpers/quby/answers_helper.rb
quby-5.1.2 app/helpers/quby/answers_helper.rb
quby-5.1.1 app/helpers/quby/answers_helper.rb
quby-5.1.0 app/helpers/quby/answers_helper.rb
quby-5.0.5 app/helpers/quby/answers_helper.rb
quby-5.0.4 app/helpers/quby/answers_helper.rb
quby-5.0.3 app/helpers/quby/answers_helper.rb
quby-5.0.2 app/helpers/quby/answers_helper.rb