Class: TaskManager::Task

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, score = nil) ⇒ Task

Returns a new instance of Task.



12
13
14
15
# File 'lib/task_manager/task.rb', line 12

def initialize(name = nil, score = nil)
  @name  = name
  @score = score
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#finished_atObject

Returns the value of attribute finished_at.



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

def finished_at
  @finished_at
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#scoreObject

Returns the value of attribute score.



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

def score
  @score
end

#started_atObject

Returns the value of attribute started_at.



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

def started_at
  @started_at
end

Class Method Details

.new_from_node(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/task_manager/task.rb', line 17

def self.new_from_node(node)
  task             = Task.new
  task.id          = node['id']
  task.name        = node['name']
  task.score       = node['score']
  task.created_at  = parse_time(node['created_at'])
  task.started_at  = parse_time(node['started_at'])
  task.finished_at = parse_time(node['finished_at'])
  task
end