Class: SteamCodec::KeyValues
- Inherits:
-
InsensitiveHash
- Object
- InsensitiveHash
- SteamCodec::KeyValues
- Defined in:
- lib/steam_codec/key_values.rb
Overview
About KeyValues => https://developer.valvesoftware.com/wiki/KeyValues Valve's implementation => https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/tier1/KeyValues.cpp SteamKit's implementation => https://github.com/SteamRE/SteamKit/blob/master/SteamKit2/SteamKit2/Types/KeyValue.cs
Direct Known Subclasses
Defined Under Namespace
Classes: Parser
Class Method Summary collapse
Instance Method Summary collapse
-
#method_missing(name, *args, &block) ⇒ Object
:nodoc:.
-
#respond_to_missing?(name, include_private = false) ⇒ Boolean
:nodoc:.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
:nodoc:
106 107 108 109 |
# File 'lib/steam_codec/key_values.rb', line 106 def method_missing(name, *args, &block) # :nodoc: return self[name] if args.empty? and block.nil? and key?(name) super end |
Class Method Details
.load(data) ⇒ Object
101 102 103 104 |
# File 'lib/steam_codec/key_values.rb', line 101 def self.load(data) json = self::Parser::toJSON(data) self.loadFromJSON(json) end |
.loadFromFile(file) ⇒ Object
95 96 97 98 99 |
# File 'lib/steam_codec/key_values.rb', line 95 def self.loadFromFile(file) raise ArgumentError, "file must respond to :read" unless file.respond_to?(:read) json = self::Parser::toJSON(file.read) self.loadFromJSON(json) end |
.loadFromJSON(json) ⇒ Object
89 90 91 92 93 |
# File 'lib/steam_codec/key_values.rb', line 89 def self.loadFromJSON(json) JSON.parse(json, {:object_class => self}) rescue JSON::ParserError nil end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
:nodoc:
111 112 113 114 |
# File 'lib/steam_codec/key_values.rb', line 111 def respond_to_missing?(name, include_private = false) # :nodoc: return true if key?(name) super end |