Class: OStruct

Inherits:
OpenStruct show all
Defined in:
lib/shorthand.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ OStruct

Returns a new instance of OStruct.



391
392
393
394
395
396
397
398
399
# File 'lib/shorthand.rb', line 391

def initialize(hash=nil)
  @table = OrderedHash.new
  if hash
    for k,v in hash
      @table[k.to_sym] = v
      new_ostruct_member(k)
    end
  end
end

Instance Method Details

#ppObject



402
# File 'lib/shorthand.rb', line 402

def pp() marshal_dump.map{|k,v| "#{k.to_s.ljust(24)} = #{String===v ? v : v.pretty_inspect.strip}"}.join("\n") end

#to_hObject



401
# File 'lib/shorthand.rb', line 401

def to_h() self.marshal_dump end

#to_sigObject



404
# File 'lib/shorthand.rb', line 404

def to_sig() marshal_dump.to_sig end

#|(other_ostruct) ⇒ Object



403
# File 'lib/shorthand.rb', line 403

def |(other_ostruct) OStruct.new(marshal_dump.merge(other_ostruct.marshal_dump.reject{|k,v|v.nil?})) end