Class: Leonidas::Commands::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/leonidas/commands/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, data, timestamp, connection) ⇒ Command

Returns a new instance of Command.

Raises:

  • (TypeError)


8
9
10
11
12
13
14
15
# File 'lib/leonidas/commands/command.rb', line 8

def initialize(name, data, timestamp, connection)
	@name = name
	@data = data
	@timestamp = timestamp

	raise TypeError, "Argument must be a Leonidas::App::Connection" unless connection.is_a? ::Leonidas::App::Connection
	@connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/leonidas/commands/command.rb', line 6

def connection
  @connection
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/leonidas/commands/command.rb', line 6

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/leonidas/commands/command.rb', line 6

def name
  @name
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



6
7
8
# File 'lib/leonidas/commands/command.rb', line 6

def timestamp
  @timestamp
end

Instance Method Details

#to_hashObject



17
18
19
# File 'lib/leonidas/commands/command.rb', line 17

def to_hash
	{ name: @name, data: @data, timestamp: @timestamp, connection: @connection.id }
end