Class: SomTimer::ExerciseFacade

Inherits:
Object
  • Object
show all
Defined in:
lib/som_timer/facades/exercise_facade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ExerciseFacade

Returns a new instance of ExerciseFacade.



4
5
6
7
# File 'lib/som_timer/facades/exercise_facade.rb', line 4

def initialize(path)
  @path = path
  @service = SomTimer::Service.new(@path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



2
3
4
# File 'lib/som_timer/facades/exercise_facade.rb', line 2

def path
  @path
end

Instance Method Details

#exercisesObject



17
18
19
20
21
22
23
# File 'lib/som_timer/facades/exercise_facade.rb', line 17

def exercises
  exercises_info = response_exercises[:exercises]

  exercises_info.map do |exercise|
    SomTimer::Exercise.new(exercise)
  end
end

#rand_exercise(duration, category) ⇒ Object



25
26
27
# File 'lib/som_timer/facades/exercise_facade.rb', line 25

def rand_exercise(duration, category)
  SomTimer::Exercise.new(response_rand_exercise(duration, category))
end

#response_exercisesObject



9
10
11
# File 'lib/som_timer/facades/exercise_facade.rb', line 9

def response_exercises
  @service.exercises
end

#response_rand_exercise(duration, category) ⇒ Object



13
14
15
# File 'lib/som_timer/facades/exercise_facade.rb', line 13

def response_rand_exercise(duration, category)
  @service.rand_exercise(duration, category)
end