Class: Argumenta::Objects::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/argumenta/objects/argument.rb

Overview

An argument includes a title, premises, and conclusion. It has an associated object record and SHA-1 hash. The object record is similar to Git’s tree. The SHA-1 identifies the argument.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, premises, conclusion) ⇒ Argument

Initializes a new argument.

title = "My Argument ^_^"
premises = [
    "The first premise!",
    "The second premise!"
]
conclusion = "The conclusion."
argument = Argument.new title, premises, conclusion


21
22
23
24
25
# File 'lib/argumenta/objects/argument.rb', line 21

def initialize(title, premises, conclusion)
  @title = title
  @premises = premises.map { |p| Proposition.new p }
  @conclusion = Proposition.new conclusion
end

Instance Attribute Details

#conclusionObject

Returns the value of attribute conclusion.



9
10
11
# File 'lib/argumenta/objects/argument.rb', line 9

def conclusion
  @conclusion
end

#premisesObject

Returns the value of attribute premises.



9
10
11
# File 'lib/argumenta/objects/argument.rb', line 9

def premises
  @premises
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/argumenta/objects/argument.rb', line 9

def title
  @title
end

Instance Method Details

#recordObject

Gets the argument’s object record.

record = argument.record


31
32
33
34
35
36
37
38
39
# File 'lib/argumenta/objects/argument.rb', line 31

def record
  head = "argument\n\n"
  body = "title #{@title}\n"
  @premises.each do |p|
    body += "premise #{p.sha1}\n"
  end
  body += "conclusion #{@conclusion.sha1}\n"
  record = head + body
end

#sha1Object

Gets the argument’s SHA-1.

sha1 = argument.sha1


45
46
47
# File 'lib/argumenta/objects/argument.rb', line 45

def sha1
  Digest::SHA1.hexdigest self.record
end