Class: Catlogic::PremisePair
- Inherits:
-
Object
- Object
- Catlogic::PremisePair
- Defined in:
- lib/catlogic/premise_pair.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
Instance Method Summary collapse
-
#initialize(major, minor) ⇒ PremisePair
constructor
A new instance of PremisePair.
- #majorterm ⇒ Object
- #middle ⇒ Object
- #minorterm ⇒ Object
-
#possible_conclusions ⇒ Object
still need a test for this.
- #three_term_pair? ⇒ Boolean
Constructor Details
#initialize(major, minor) ⇒ PremisePair
Returns a new instance of PremisePair.
6 7 8 9 |
# File 'lib/catlogic/premise_pair.rb', line 6 def initialize(major, minor) @major = major @minor = minor end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
4 5 6 |
# File 'lib/catlogic/premise_pair.rb', line 4 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
4 5 6 |
# File 'lib/catlogic/premise_pair.rb', line 4 def minor @minor end |
Instance Method Details
#majorterm ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/catlogic/premise_pair.rb', line 35 def majorterm if @major.subject.label == self.middle.label majorterm = @major.predicate else majorterm = @major.subject end majorterm end |
#middle ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/catlogic/premise_pair.rb', line 11 def middle termarray = [@major.subject.label, @major.predicate.label, @minor.subject.label, @minor.predicate.label] middle = nil if self.three_term_pair? termarray.detect do |term| if termarray.count(term) == 2 middle = Term.new(term) end end else middle = "Error: this is not a three term syllogism" end return middle end |
#minorterm ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/catlogic/premise_pair.rb', line 43 def minorterm if @minor.subject.label == self.middle.label minorterm = @minor.predicate else minorterm = @minor.subject end minorterm end |
#possible_conclusions ⇒ Object
still need a test for this
53 54 55 56 57 58 59 60 61 |
# File 'lib/catlogic/premise_pair.rb', line 53 def possible_conclusions possible_conclusions = [ Proposition.new(Quantity.new("universal"), self.minorterm, Quality.new("affirmative"), self.majorterm, true), Proposition.new(Quantity.new("universal"), self.minorterm, Quality.new("negative"), self.majorterm, true), Proposition.new(Quantity.new("particular"), self.minorterm, Quality.new("affirmative"), self.majorterm, true), Proposition.new(Quantity.new("particular"), self.minorterm, Quality.new("negative"), self.majorterm, true) ] return possible_conclusions end |
#three_term_pair? ⇒ Boolean
26 27 28 29 30 31 32 33 |
# File 'lib/catlogic/premise_pair.rb', line 26 def three_term_pair? termarray = [@major.subject.label, @major.predicate.label, @minor.subject.label, @minor.predicate.label] if termarray.uniq.size == 3 answer = true else answer = false end end |