Class: BloodContracts::Contracts::Description

Inherits:
Object
  • Object
show all
Defined in:
lib/blood_contracts/contracts/description.rb

Class Method Summary collapse

Class Method Details

.call(contract_hash) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/blood_contracts/contracts/description.rb', line 4

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