Class: Markify::Mark
- Inherits:
-
Object
- Object
- Markify::Mark
- 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
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#passed ⇒ Object
readonly
Returns the value of attribute passed.
-
#try ⇒ Object
readonly
Returns the value of attribute try.
Instance Method Summary collapse
-
#initialize(name, id, mark, passed, try, date) ⇒ Mark
constructor
A new instance of Mark.
- #to_s ⇒ Object
- #to_sha256 ⇒ Object
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
#date ⇒ Object (readonly)
Returns the value of attribute date.
23 24 25 |
# File 'lib/markify/mark.rb', line 23 def date @date end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
23 24 25 |
# File 'lib/markify/mark.rb', line 23 def hash @hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
23 24 25 |
# File 'lib/markify/mark.rb', line 23 def id @id end |
#mark ⇒ Object (readonly)
Returns the value of attribute mark.
23 24 25 |
# File 'lib/markify/mark.rb', line 23 def mark @mark end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/markify/mark.rb', line 23 def name @name end |
#passed ⇒ Object (readonly)
Returns the value of attribute passed.
23 24 25 |
# File 'lib/markify/mark.rb', line 23 def passed @passed end |
#try ⇒ Object (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_s ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/markify/mark.rb', line 35 def to_s =<<MESSAGE exam: #{@name} mark: #{@mark} passed: #{@passed} try: #{@try} date: #{@date} hash: #{@hash} MESSAGE end |
#to_sha256 ⇒ Object
48 49 50 |
# File 'lib/markify/mark.rb', line 48 def to_sha256 Digest::SHA256.new << "#{@name}#{@id}#{@date}#{@mark}#{@try}#{@passed}" end |