Class: Belajar::Views::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/belajar/views/subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(courses_menu:, chapters_menu:, units_menu:, task_view:) ⇒ Subscriber

Returns a new instance of Subscriber.



6
7
8
9
10
11
# File 'lib/belajar/views/subscriber.rb', line 6

def initialize(courses_menu:, chapters_menu:, units_menu:, task_view:)
  @courses_menu  = courses_menu
  @chapters_menu = chapters_menu
  @units_menu    = units_menu
  @task_view     = task_view
end

Instance Attribute Details

#chapters_menuObject (readonly)

Returns the value of attribute chapters_menu.



4
5
6
# File 'lib/belajar/views/subscriber.rb', line 4

def chapters_menu
  @chapters_menu
end

#courses_menuObject (readonly)

Returns the value of attribute courses_menu.



4
5
6
# File 'lib/belajar/views/subscriber.rb', line 4

def courses_menu
  @courses_menu
end

#task_viewObject (readonly)

Returns the value of attribute task_view.



4
5
6
# File 'lib/belajar/views/subscriber.rb', line 4

def task_view
  @task_view
end

#units_menuObject (readonly)

Returns the value of attribute units_menu.



4
5
6
# File 'lib/belajar/views/subscriber.rb', line 4

def units_menu
  @units_menu
end

Instance Method Details

#subscribe_bottom_up_navigationObject



25
26
27
28
29
# File 'lib/belajar/views/subscriber.rb', line 25

def subscribe_bottom_up_navigation
  chapters_menu.subscribe(courses_menu, on: :reenter)
  units_menu.subscribe(chapters_menu, on: :reenter)
  task_view.subscribe(units_menu, on: :reenter)
end

#subscribe_events!Object



13
14
15
16
17
# File 'lib/belajar/views/subscriber.rb', line 13

def subscribe_events!
  subscribe_top_down_navigation
  subscribe_bottom_up_navigation
  subscribe_menu_position_reset
end

#subscribe_menu_position_resetObject



31
32
33
34
35
# File 'lib/belajar/views/subscriber.rb', line 31

def subscribe_menu_position_reset
  courses_menu.subscribe(chapters_menu, on: :reset_menu_position)
  courses_menu.subscribe(units_menu, on: :reset_menu_position)
  chapters_menu.subscribe(units_menu, on: :reset_menu_position)
end

#subscribe_top_down_navigationObject



19
20
21
22
23
# File 'lib/belajar/views/subscriber.rb', line 19

def subscribe_top_down_navigation
  courses_menu.subscribe(chapters_menu, on: :enter)
  chapters_menu.subscribe(units_menu, on: :enter)
  units_menu.subscribe(task_view, on: :enter)
end