Class: Julius

Inherits:
Object
  • Object
show all
Defined in:
lib/julius.rb,
lib/julius/prompt.rb,
lib/julius/command.rb,
lib/julius/message.rb,
lib/julius/version.rb

Defined Under Namespace

Classes: Command, Message, Prompt

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Constructor Details

#initialize(arg = {}) ⇒ Julius

Returns a new instance of Julius.



9
10
11
12
# File 'lib/julius.rb', line 9

def initialize(arg = {})
  @host = arg[:host] || 'localhost'
  @port = arg[:port] || 10500
end

Instance Method Details

#each_messageObject



14
15
16
17
18
19
20
21
22
# File 'lib/julius.rb', line 14

def each_message
  return self.to_enum(__method__) unless block_given?
  socket = TCPSocket.new(@host, @port)
  prompt = Prompt.new(socket)
  xml_enum(socket).each do |xml|
    yield(Message.init(xml), prompt)
  end
  self
end