Method: Whatup::CLI::Interactive#room

Defined in:
lib/whatup/cli/commands/interactive/interactive.rb

#room(name) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/whatup/cli/commands/interactive/interactive.rb', line 54

def room name
  if room = Room.find_by(name: name)
    current_user.puts "      Entering \#{room.name}... enjoy your stay!\n\n      Type `.exit` to exit this chat room.\n\n      Currently in this room:\n      \#{room.clients.map do |client|\n          \"- \#{client.name}\\n\"\n        end.join}\n    MSG\n    current_user.update! room: room\n\n    server.clients.reject { |c| c.id == current_user.id }.each do |c|\n      c.puts <<~MSG\n        \#{current_user.name} has arrived! Play nice, kids.\n      MSG\n    end\n\n    room.clients << current_user\n    return\n  end\n\n  room = server.new_room! name: name, clients: [current_user]\n\n  current_user.puts <<~MSG\n    Created and entered \#{room.name}... invite some people or something!\n\n    Type `.exit` to exit this chat room.\n  MSG\nend\n"