Class: Ruby::Pomodoro::Tasks::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/pomodoro/tasks/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, spent_time: 0, id: nil) ⇒ Entity

Returns a new instance of Entity.



7
8
9
10
11
12
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 7

def initialize(name:, spent_time: 0, id: nil)
  @name = name
  @spent_time = spent_time
  @pomodors = 0
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 5

def name
  @name
end

#pomodorsObject (readonly)

Returns the value of attribute pomodors.



5
6
7
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 5

def pomodors
  @pomodors
end

#spent_timeObject (readonly)

Returns the value of attribute spent_time.



5
6
7
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 5

def spent_time
  @spent_time
end

Instance Method Details

#add_pomodoroInteger

Returns:

  • (Integer)


15
16
17
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 15

def add_pomodoro
  @pomodors += 1
end

#track(seconds) ⇒ Integer

Parameters:

  • seconds (Integer)

Returns:

  • (Integer)


21
22
23
# File 'lib/ruby/pomodoro/tasks/entity.rb', line 21

def track(seconds)
  @spent_time += seconds
end