Class: Notes::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/notes/model/note.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 options
  @tag = (options[Options::TAG] && options[Options::TAG] != [])? options[Options::TAG] : 'unspecified'
  @description = options[Options::DESCRIPTION] ? options[Options::DESCRIPTION] : 'unspecified'
  @due_date = options[Options::DUE_DATE] ? options[Options::DUE_DATE] : 'unspecified'
  @token = options[Options::TOKEN] ? options[Options::TOKEN] : 'unspecified'
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/notes/model/note.rb', line 3

def description
  @description
end

#due_dateObject (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

#tagObject (readonly)

Returns the value of attribute tag.



3
4
5
# File 'lib/notes/model/note.rb', line 3

def tag
  @tag
end

#tokenObject (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_tokenObject



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_hashObject



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