Class: CarbonMU::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/carbonmu/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Connection

TODO probably need edge type (:telnet, :ssl, etc), or at least interactive true/false



8
9
10
11
12
# File 'lib/carbonmu/connection.rb', line 8

def initialize(id)
  @id = id
  @locale = "en" # TODO configurable default locale
  @player = nil
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/carbonmu/connection.rb', line 3

def id
  @id
end

#localeObject

Returns the value of attribute locale.



4
5
6
# File 'lib/carbonmu/connection.rb', line 4

def locale
  @locale
end

#playerObject

Returns the value of attribute player.



5
6
7
# File 'lib/carbonmu/connection.rb', line 5

def player
  @player
end

Instance Method Details

#write_translated(msg, args = {}) ⇒ Object



14
15
16
17
# File 'lib/carbonmu/connection.rb', line 14

def write_translated(msg, args = {})
  translation_args = args.merge(locale: @locale)
  CarbonMU.server.write_to_connection(id, I18n.t(msg, translation_args) + "\n")
end