Class: Interpretation

Inherits:
Object
  • Object
show all
Defined in:
lib/logical/interpretation.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Interpretation

Returns a new instance of Interpretation.



4
5
6
# File 'lib/logical/interpretation.rb', line 4

def initialize(hash)
  @hash = hash
end

Class Method Details

.all(letters) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/logical/interpretation.rb', line 16

def self.all(letters)
  [true, false]
    .repeated_permutation(letters.size)
    .map do |disposition|
    mapping = {}
    letters.each_with_index do |letter, i|
      mapping[letter] = disposition[i]
    end
    Interpretation.new(mapping)
  end
end

Instance Method Details

#evaluate(letter) ⇒ Object



8
9
10
# File 'lib/logical/interpretation.rb', line 8

def evaluate(letter)
  @hash[letter]
end

#to_sObject



12
13
14
# File 'lib/logical/interpretation.rb', line 12

def to_s
  @hash.to_s
end