Sha256: 16a1d547b1c870964b89bc6313910bb9544de9f886c7bd36048185935803cfd2

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

module Leap
  # Encapsulates a single computation of a Leap subject's decision, as performed on an instance of that subject class.
  class Deliberation
    # Accumulates knowledge about the Leap subject instance, beginning with the instance's explicit attributes, and later augmented by committee proceedings.
    attr_accessor :characteristics
    
    # Accumulates proceedings of the deliberation, including conclusions and methodology.
    attr_accessor :reports
    
    # Create a new deliberation, to be made in light of the provided characteristics of the Leap subject instance.
    # @param [Hash] characteristics The initial set of characteristics made available to committees during deliberation. 
    def initialize(characteristics)
      self.characteristics = characteristics
      self.reports = []
    end
    
    # Convenience method to access values within the deliberation's characteristics hash.
    # @param [Symbol] characteristic
    def [](characteristic)
      characteristics[characteristic]
    end
    
    # Report which named protocols the deliberation incidentally complied with.
    # @return [Array]
    def compliance
      reports.map(&:quorum).map(&:compliance).inject do |memo, c|
        next c unless memo
        memo & c
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
leap-0.5.6 lib/leap/deliberation.rb
leap-0.5.5 lib/leap/deliberation.rb
leap-0.5.4 lib/leap/deliberation.rb
leap-0.5.3 lib/leap/deliberation.rb
leap-0.5.2 lib/leap/deliberation.rb
leap-0.5.1 lib/leap/deliberation.rb
leap-0.5.0 lib/leap/deliberation.rb