Class: SteamCodec::KeyValues

Inherits:
InsensitiveHash
  • Object
show all
Defined in:
lib/steam_codec/key_values.rb

Overview

Direct Known Subclasses

VDF

Defined Under Namespace

Classes: Parser

Class Method Summary collapse

Instance Method Summary collapse

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

Raises:

  • (ArgumentError)


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