Class: Hash
- Defined in:
- lib/openc3/core_ext/hash.rb,
lib/openc3/io/json_rpc.rb,
lib/openc3/config/meta_config_parser.rb
Overview
OpenC3 specific additions to the Ruby Hash class
Instance Method Summary collapse
-
#as_json(options = nil) ⇒ Object
:nodoc:.
-
#inspect(max_elements = 10) ⇒ String
String representation of the hash.
-
#old_inspect ⇒ Object
Redefine inspect to only print for small numbers of items.
- #to_meta_config_yaml(indentation = 0) ⇒ Object
Instance Method Details
#as_json(options = nil) ⇒ Object
:nodoc:
117 118 119 120 121 |
# File 'lib/openc3/io/json_rpc.rb', line 117 def as_json( = nil) #:nodoc: hash = {} self.each {|k,v| hash[k.to_s] = v.as_json() } hash end |
#inspect(max_elements = 10) ⇒ String
Returns String representation of the hash.
33 34 35 36 37 38 39 |
# File 'lib/openc3/core_ext/hash.rb', line 33 def inspect(max_elements = 10) if self.length <= max_elements old_inspect() else '#<' + self.class.to_s + ':' + self.object_id.to_s + '>' end end |
#old_inspect ⇒ Object
Redefine inspect to only print for small numbers of items. Prevents exceptions taking forever to be raised with large objects. See blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105145
28 |
# File 'lib/openc3/core_ext/hash.rb', line 28 alias old_inspect inspect |
#to_meta_config_yaml(indentation = 0) ⇒ Object
35 36 37 |
# File 'lib/openc3/config/meta_config_parser.rb', line 35 def (indentation = 0) Psych.dump(self).split("\n")[1..-1].join("\n#{' ' * indentation}") end |