Class: PG::Coder

Inherits:
Object show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb

Direct Known Subclasses

CompositeCoder, CopyCoder, RecordCoder

Defined Under Namespace

Modules: BinaryFormatting

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Coder

Create a new coder object based on the attribute Hash.



17
18
19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 17

def initialize(params={})
  params.each do |key, val|
    send("#{key}=", val)
  end
end

Instance Method Details

#==(v) ⇒ Object



37
38
39
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 37

def ==(v)
  self.class == v.class && to_h == v.to_h
end

#dupObject



23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 23

def dup
  self.class.new(to_h)
end

#inspectObject



49
50
51
52
53
54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 49

def inspect
  str = self.to_s
  oid_str = " oid=#{oid}" unless oid==0
  format_str = " format=#{format}" unless format==0
  name_str = " #{name.inspect}" if name
  str[-1,0] = "#{name_str} #{oid_str}#{format_str}"
  str
end

#inspect_shortObject



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 58

def inspect_short
  str = case format
    when 0 then "T"
    when 1 then "B"
    else format.to_s
  end
  str += "E" if respond_to?(:encode)
  str += "D" if respond_to?(:decode)

  "#{name || self.class.name}:#{str}"
end

#marshal_dumpObject



41
42
43
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 41

def marshal_dump
  Marshal.dump(to_h)
end

#marshal_load(str) ⇒ Object



45
46
47
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 45

def marshal_load(str)
  initialize Marshal.load(str)
end

#to_hObject

Returns coder attributes as Hash.



28
29
30
31
32
33
34
35
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pg-1.4.5/lib/pg/coder.rb', line 28

def to_h
  {
    oid: oid,
    format: format,
    flags: flags,
    name: name,
  }
end