Class: Catlogic::Form

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mood, figure) ⇒ Form

takes three Mood Object and Figure Object



5
6
7
8
9
# File 'lib/catlogic/form.rb', line 5

def initialize(mood, figure)
  @mood = mood.to_mood
  @figure = figure.to_figure
  @label = "#{@mood.label}#{@figure.label}"
end

Instance Attribute Details

#figureObject (readonly)

Returns the value of attribute figure.



3
4
5
# File 'lib/catlogic/form.rb', line 3

def figure
  @figure
end

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/catlogic/form.rb', line 3

def label
  @label
end

#moodObject (readonly)

Returns the value of attribute mood.



3
4
5
# File 'lib/catlogic/form.rb', line 3

def mood
  @mood
end

Instance Method Details

#nameObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/catlogic/form.rb', line 23

def name
  case @figure.label
    when 1
      case @mood.label
        when "AAA"
          name = "Barbara"
        when "EAE"
          name = "Celarent"
        when "AII"
          name = "Darii"
        when "EIO"
          name = "Ferio"
        when "AAI"
          name = "Barbari"
        when "EAO"
          name = "Celaront"
        else
          name = nil
      end
    when 2
      case @mood.label
        when "EAE"
          name = "Cesare"
        when "AEE"
          name = "Camestres"
        when "EIO"
          name = "Festino"
        when "AOO"
          name = "Baroco"
        when "EAO"
          name = "Cesaro"
        when "AEO"
          name = "Camestrop"
        else
          name = nil
      end
    when 3
      case @mood.label
        when "AAI"
          name = "Darapti"
        when "IAI"
          name = "Disamis"
        when "AII"
          name = "Datisi"
        when "EAO"
          name = "Felapton"
        when "OAO"
          name = "Bocardo"
        when "EIO"
          name = "Ferison"
        else
          name = nil
      end
    when 4
      case @mood.label
        when "AAI"
          name = "Bramantip"
        when "AEE"
          name = "Camenes"
        when "IAI"
          name = "Festino"
        when "EAO"
          name = "Fesapo"
        when "EIO"
          name = "Fresison"
        when "AEO"
          name = "Camenop"
        else
          name = nil
      end
    else
      name = nil
  end
  return name
end

#syllogismObject



10
11
12
13
14
15
16
17
18
# File 'lib/catlogic/form.rb', line 10

def syllogism
   majorproposition = Proposition.new(@mood.majortype.quantity, @figure.major_subject, @mood.majortype.quality, @figure.major_predicate, true)
  minorproposition = Proposition.new(@mood.minortype.quantity, @figure.minor_subject, @mood.minortype.quality, @figure.minor_predicate, true)
  conclusion = Proposition.new(@mood.conclusiontype.quantity, Term.new("S"), @mood.conclusiontype.quality, Term.new("P"), true)

  syllogism = Syllogism.new(majorproposition, minorproposition, conclusion)

  return syllogism
end

#validityObject



19
20
21
22
# File 'lib/catlogic/form.rb', line 19

def validity
  syllogism = self.syllogism
  syllogism.validity
end