Class: Lita::WeeklySchedule
- Inherits:
-
Object
- Object
- Lita::WeeklySchedule
- Defined in:
- lib/lita/weekly_schedule.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#room_id ⇒ Object
readonly
Returns the value of attribute room_id.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #human ⇒ Object
-
#initialize(id:, room_id:, user_id:, day:, time:, cmd:) ⇒ WeeklySchedule
constructor
A new instance of WeeklySchedule.
- #name ⇒ Object
- #run(*args) ⇒ Object
- #to_json ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(id:, room_id:, user_id:, day:, time:, cmd:) ⇒ WeeklySchedule
Returns a new instance of WeeklySchedule.
5 6 7 8 9 10 |
# File 'lib/lita/weekly_schedule.rb', line 5 def initialize(id:, room_id:, user_id:, day:, time:, cmd:) @id = id @room_id, @user_id = room_id, user_id @day, @time = day.to_s.to_sym, time.to_s @cmd = cmd.new if cmd end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
3 4 5 |
# File 'lib/lita/weekly_schedule.rb', line 3 def cmd @cmd end |
#day ⇒ Object (readonly)
Returns the value of attribute day.
3 4 5 |
# File 'lib/lita/weekly_schedule.rb', line 3 def day @day end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/lita/weekly_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/weekly_schedule.rb', line 3 def room_id @room_id end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
3 4 5 |
# File 'lib/lita/weekly_schedule.rb', line 3 def time @time end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
3 4 5 |
# File 'lib/lita/weekly_schedule.rb', line 3 def user_id @user_id end |
Instance Method Details
#human ⇒ Object
35 36 37 |
# File 'lib/lita/weekly_schedule.rb', line 35 def human "Weekly (id: #{@id}): #{@day} #{@time} - #{@cmd.name}" end |
#name ⇒ Object
12 13 14 |
# File 'lib/lita/weekly_schedule.rb', line 12 def name @cmd.name end |
#run(*args) ⇒ Object
16 17 18 |
# File 'lib/lita/weekly_schedule.rb', line 16 def run(*args) @cmd.run(*args) end |
#to_json ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lita/weekly_schedule.rb', line 24 def to_json { id: @id, day: @day, time: @time, cmd: @cmd.name, user_id: @user_id, room_id: @room_id, }.to_json end |
#valid? ⇒ Boolean
20 21 22 |
# File 'lib/lita/weekly_schedule.rb', line 20 def valid? room_id && user_id && valid_day? && valid_time? && valid_cmd? end |