Class: QStat::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-qstat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



25
26
27
# File 'lib/ruby-qstat.rb', line 25

def address
  @address
end

#docObject

Returns the value of attribute doc.



27
28
29
# File 'lib/ruby-qstat.rb', line 27

def doc
  @doc
end

#gamenameObject

Returns the value of attribute gamename.



29
30
31
# File 'lib/ruby-qstat.rb', line 29

def gamename
  @gamename
end

#gametypeObject

Returns the value of attribute gametype.



28
29
30
# File 'lib/ruby-qstat.rb', line 28

def gametype
  @gametype
end

#xmlObject

Returns the value of attribute xml.



26
27
28
# File 'lib/ruby-qstat.rb', line 26

def xml
  @xml
end

Instance Method Details

#status_codeObject



31
32
33
34
35
36
37
38
39
# File 'lib/ruby-qstat.rb', line 31

def status_code
  server = @doc.search("/qstat/server[1]").first
  if server.attributes["type"].value.upcase == @gametype.upcase
    if server.attributes["address"].value == @address
      return server.attributes["status"].value
    end
  end
  nil
end

#to_rorObject



54
55
56
# File 'lib/ruby-qstat.rb', line 54

def to_ror
  Hash.from_xml(@doc.to_s)
end

#to_sObject



50
51
52
# File 'lib/ruby-qstat.rb', line 50

def to_s
  @xml
end

#valid?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
46
47
48
# File 'lib/ruby-qstat.rb', line 41

def valid?
  case status_code
  when "UP"
    true
  else
    false
  end
end