Sha256: e4d3ba0cdd96244eef7f4189637b7146b62a94d818e2f6bc51f0a306f198b53b

Contents?: true

Size: 718 Bytes

Versions: 2

Compression:

Stored size: 718 Bytes

Contents

module BloodContracts
  module Contracts
    class Description
      def self.call(contract_hash)
        Hashie::Mash.new(contract_hash).map do |name, rule|
          rule_description = " - '#{name}' "
          if rule.threshold
            rule_description << <<~TEXT
              in more then #{(rule.threshold * 100).round(2)}% of cases;
            TEXT
          elsif rule.limit
            rule_description << <<~TEXT
              in less then #{(rule.limit * 100).round(2)}% of cases;
            TEXT
          else
            rule_description << <<~TEXT
              in any number of cases;
            TEXT
          end
          rule_description
        end.compact.join
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blood_contracts-0.2.1 lib/blood_contracts/contracts/description.rb
blood_contracts-0.2.0 lib/blood_contracts/contracts/description.rb