Class: Catlogic::PropositionType

Inherits:
Object
  • Object
show all
Defined in:
lib/catlogic/proposition_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, truthvalue = true) ⇒ PropositionType

Returns a new instance of PropositionType.



6
7
8
9
10
# File 'lib/catlogic/proposition_type.rb', line 6

def initialize(type, truthvalue=true)
  @type = type
  @label = type
  @truthvalue = truthvalue
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/catlogic/proposition_type.rb', line 4

def label
  @label
end

#truthvalueObject (readonly)

Returns the value of attribute truthvalue.



4
5
6
# File 'lib/catlogic/proposition_type.rb', line 4

def truthvalue
  @truthvalue
end

Instance Method Details

#propositionObject



44
45
46
47
# File 'lib/catlogic/proposition_type.rb', line 44

def proposition
  proposition = Proposition.new(Quantity.new(self.quantity.label), Term.new("S"), Quality.new(self.quality.label), Term.new("P"), @truthvalue)
  return proposition
end

#qualityObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/catlogic/proposition_type.rb', line 29

def quality
  if @label == "A"
    quality = Quality.new("affirmative")
  elsif @label == "E"
    quality = Quality.new("negative")
  elsif @label == "I"
    quality = Quality.new("affirmative")
  elsif @label == "O"
    quality = Quality.new("negative")
  else
    quality = "not a valid type"
  end
  return quality
end

#quantityObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/catlogic/proposition_type.rb', line 15

def quantity
  if @label == "A"
    quantity = Quantity.new("universal")
  elsif @label == "E"
    quantity = Quantity.new("universal")
  elsif @label == "I"
    quantity = Quantity.new("particular")
  elsif @label == "O"
    quantity = Quantity.new("particular")
  else
    quantity = "not a valid type"
  end
  return quantity
end

#to_proposition_typeObject



11
12
13
# File 'lib/catlogic/proposition_type.rb', line 11

def to_proposition_type
  self
end