class CacheXML::CacheEmitterDetail::CacheEmitter

Public Class Methods

new(out) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 9
def initialize(out)
  @e = ThinpXML::Base::Emitter.new(out)
end

Public Instance Methods

emit_hints(hs) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 27
def emit_hints(hs)
  return if no_entries(hs)

  block = lambda do
    hs.each {|h| emit_hint(h)}
  end

  @e.emit_tag(hs, 'hints', &block)
end
emit_mappings(ms) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 17
def emit_mappings(ms)
  return if no_entries(ms)

  block = lambda do
    ms.each {|m| emit_mapping(m)}
  end

  @e.emit_tag(ms, 'mappings', &block)
end
emit_superblock(sb, &block) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 13
def emit_superblock(sb, &block)
  @e.emit_tag(sb, 'superblock', :uuid, :block_size, :nr_cache_blocks, :policy, :hint_width, &block)
end

Private Instance Methods

emit_hint(h) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 46
def emit_hint(h)
  @e.emit_line("<hint cache_block=\"#{m.cache_block}\" data=\"#{h.encoded_data}\"\>")
end
emit_mapping(m) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 42
def emit_mapping(m)
  @e.emit_tag(m, 'mapping', :cache_block, :origin_block, :dirty)
end
no_entries(a) click to toggle source
# File lib/thinp_xml/cache/emit.rb, line 38
def no_entries(a)
  a.nil? || a.size == 0
end