Module: EBUR128Stream::Reportable

Included in:
NormalizeReport, Report, Snapshot
Defined in:
lib/ebur128_stream.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



40
41
42
# File 'lib/ebur128_stream.rb', line 40

def ==(other)
  deconstruct_keys(nil) == other.deconstruct_keys(nil)
end

#deconstruct_keys(keys = nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/ebur128_stream.rb', line 10

def deconstruct_keys(keys = nil)
  keys = self.class::ATTRS if keys.nil?
  (keys & self.class::ATTRS).inject({}) {|deconstructed, attr|
    deconstructed[attr] = send(attr)
    deconstructed
  }
end

#inspect ⇒ Object



18
19
20
21
22
23
# File 'lib/ebur128_stream.rb', line 18

def inspect
  "#<%{class} %{attrs}>" % {
    class: self.class,
    attrs: self.class::ATTRS.collect {|attr| "#{attr}=#{send(attr).inspect}"}.join(" ")
  }
end

#pretty_print(q) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ebur128_stream.rb', line 25

def pretty_print(q)
  attrs = self.class::ATTRS
  a_width = attrs.max_by(&:length).length

  q.object_group self do
    q.breakable
    attrs.each_with_index do |attr, index|
      q.comma_breakable unless index == 0
      q.text attr.to_s.rjust(a_width)
      q.text " = "
      q.pp send(attr)
    end
  end
end