Class: Notes::Note
- Inherits:
-
Object
- Object
- Notes::Note
- Defined in:
- lib/notes/model/note.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #get_token ⇒ Object
-
#initialize(options) ⇒ Note
constructor
A new instance of Note.
- #to_hash ⇒ Object
Constructor Details
#initialize(options) ⇒ Note
Returns a new instance of Note.
5 6 7 8 9 10 |
# File 'lib/notes/model/note.rb', line 5 def initialize @tag = ([Options::TAG] && [Options::TAG] != [])? [Options::TAG] : 'unspecified' @description = [Options::DESCRIPTION] ? [Options::DESCRIPTION] : 'unspecified' @due_date = [Options::DUE_DATE] ? [Options::DUE_DATE] : 'unspecified' @token = [Options::TOKEN] ? [Options::TOKEN] : 'unspecified' end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/notes/model/note.rb', line 3 def description @description end |
#due_date ⇒ Object (readonly)
Returns the value of attribute due_date.
3 4 5 |
# File 'lib/notes/model/note.rb', line 3 def due_date @due_date end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
3 4 5 |
# File 'lib/notes/model/note.rb', line 3 def tag @tag end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
3 4 5 |
# File 'lib/notes/model/note.rb', line 3 def token @token end |
Instance Method Details
#get_token ⇒ Object
21 22 23 |
# File 'lib/notes/model/note.rb', line 21 def get_token @tag.hash * 1231 + @description.hash * 1237 + @due_date.hash * 37 end |
#to_hash ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/notes/model/note.rb', line 12 def to_hash result_hash = {} result_hash[Options::TAG.to_s] = @tag result_hash[Options::DESCRIPTION.to_s] = @description result_hash[Options::DUE_DATE.to_s] = @due_date result_hash[Options::TOKEN.to_s] = get_token.to_s result_hash end |