Class: Lita::WindowSchedule
- Inherits:
-
Object
- Object
- Lita::WindowSchedule
- Defined in:
- lib/lita/window_schedule.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#room_id ⇒ Object
readonly
Returns the value of attribute room_id.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #buffer_minutes ⇒ Object
- #duration_minutes ⇒ Object
- #human ⇒ Object
-
#initialize(id:, room_id:, user_id:, cmd:) ⇒ WindowSchedule
constructor
A new instance of WindowSchedule.
- #name ⇒ Object
- #run(*args) ⇒ Object
- #to_json ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(id:, room_id:, user_id:, cmd:) ⇒ WindowSchedule
5 6 7 8 9 |
# File 'lib/lita/window_schedule.rb', line 5 def initialize(id:, room_id:, user_id:, cmd:) @id = id @room_id, @user_id = room_id, user_id @cmd = cmd.new if cmd end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
3 4 5 |
# File 'lib/lita/window_schedule.rb', line 3 def cmd @cmd end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/lita/window_schedule.rb', line 3 def id @id end |
#room_id ⇒ Object (readonly)
Returns the value of attribute room_id.
3 4 5 |
# File 'lib/lita/window_schedule.rb', line 3 def room_id @room_id end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
3 4 5 |
# File 'lib/lita/window_schedule.rb', line 3 def user_id @user_id end |
Instance Method Details
#buffer_minutes ⇒ Object
15 16 17 |
# File 'lib/lita/window_schedule.rb', line 15 def buffer_minutes @cmd.buffer_minutes end |
#duration_minutes ⇒ Object
11 12 13 |
# File 'lib/lita/window_schedule.rb', line 11 def duration_minutes @cmd.duration_minutes end |
#human ⇒ Object
27 28 29 |
# File 'lib/lita/window_schedule.rb', line 27 def human "Sliding Window (id: #{@id}): #{@cmd.name}" end |
#name ⇒ Object
19 20 21 |
# File 'lib/lita/window_schedule.rb', line 19 def name @cmd.name end |
#run(*args) ⇒ Object
23 24 25 |
# File 'lib/lita/window_schedule.rb', line 23 def run(*args) @cmd.run(*args) end |
#to_json ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/lita/window_schedule.rb', line 35 def to_json { id: @id, cmd: @cmd.name, user_id: @user_id, room_id: @room_id, }.to_json end |
#valid? ⇒ Boolean
31 32 33 |
# File 'lib/lita/window_schedule.rb', line 31 def valid? room_id && user_id && valid_cmd? end |