Class: TodoModel

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

Overview

Model of the Todo entity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, description, status = :pending) ⇒ TodoModel

Returns a new instance of TodoModel.



9
10
11
12
13
# File 'lib/todo_model.rb', line 9

def initialize(id, description, status = :pending)
  @id = id
  @description = description
  @status = status
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/todo_model.rb', line 6

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/todo_model.rb', line 5

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/todo_model.rb', line 7

def status
  @status
end

Instance Method Details

#as_hashObject



19
20
21
# File 'lib/todo_model.rb', line 19

def as_hash
  { 'id': id, 'description': description, 'status': status }
end

#completeObject



15
16
17
# File 'lib/todo_model.rb', line 15

def complete
  @status = :completed
end