Class: Struct

Inherits:
Object show all
Defined in:
lib/pp.rb,
lib/yaml/rubytypes.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) yaml_new(val)



74
75
76
77
78
# File 'lib/yaml/rubytypes.rb', line 74

def self.yaml_new(val)
  obj = self.new
  val.each { |k, v| obj[k] = v }
  obj
end

Instance Method Details

- (Object) pretty_print(q)



370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/pp.rb', line 370

def pretty_print(q)
  q.group(1, sprintf("#<struct %s", PP.mcall(self, Kernel, :class).name), '>') {
    q.seplist(PP.mcall(self, Struct, :members), lambda { q.text "," }) {|member|
      q.breakable
      q.text member.to_s
      q.text '='
      q.group(1) {
        q.breakable ''
        q.pp self[member]
      }
    }
  }
end

- (Object) pretty_print_cycle(q)



384
385
386
# File 'lib/pp.rb', line 384

def pretty_print_cycle(q)
  q.text sprintf("#<struct %s:...>", PP.mcall(self, Kernel, :class).name)
end

- (Object) to_yaml(output = nil)



64
65
66
67
68
69
70
71
72
# File 'lib/yaml/rubytypes.rb', line 64

def to_yaml(output = nil)
  YAML::quick_emit(output) do |out|
    out.map(taguri, to_yaml_style) do |map|
      members.each do |m|
        out.add(m.to_s, self[m])
      end
    end
  end
end