Class: Markify::Mark

Inherits:
Object
  • Object
show all
Defined in:
lib/markify/mark.rb

Overview

Copyright Daniel Meißner <[email protected]>, 2013

This file is part of Markify.

Markify is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Markify is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Markify. If not, see <www.gnu.org/licenses/>.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id, mark, passed, try, date) ⇒ Mark

Returns a new instance of Mark.



25
26
27
28
29
30
31
32
33
# File 'lib/markify/mark.rb', line 25

def initialize(name, id, mark, passed, try, date)
  @name   = name
  @id     = id.to_i
  @mark   = mark.to_f
  @passed = passed
  @try    = try.to_i
  @date   = Date.strptime(date, '%d.%m.%Y')
  @hash   = self.to_sha256.to_s
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



23
24
25
# File 'lib/markify/mark.rb', line 23

def date
  @date
end

#hashObject (readonly)

Returns the value of attribute hash.



23
24
25
# File 'lib/markify/mark.rb', line 23

def hash
  @hash
end

#idObject (readonly)

Returns the value of attribute id.



23
24
25
# File 'lib/markify/mark.rb', line 23

def id
  @id
end

#markObject (readonly)

Returns the value of attribute mark.



23
24
25
# File 'lib/markify/mark.rb', line 23

def mark
  @mark
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/markify/mark.rb', line 23

def name
  @name
end

#passedObject (readonly)

Returns the value of attribute passed.



23
24
25
# File 'lib/markify/mark.rb', line 23

def passed
  @passed
end

#tryObject (readonly)

Returns the value of attribute try.



23
24
25
# File 'lib/markify/mark.rb', line 23

def try
  @try
end

Instance Method Details

#to_sObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/markify/mark.rb', line 35

def to_s
  message =<<MESSAGE
exam:   #{@name}
mark:   #{@mark}
passed: #{@passed}
try:    #{@try}
date:   #{@date}

hash:   #{@hash}

MESSAGE
end

#to_sha256Object



48
49
50
# File 'lib/markify/mark.rb', line 48

def to_sha256
  Digest::SHA256.new << "#{@name}#{@id}#{@date}#{@mark}#{@try}#{@passed}"
end