Sha256: b0e0970e7acf220fb7fa85239e6f3476cde07aac17e7b555d019a845b5d463a2

Contents?: true

Size: 841 Bytes

Versions: 5

Compression:

Stored size: 841 Bytes

Contents

module WWMD
  class VSHashtable < VSClassHelpers
    attr_accessor :value

    def initialize()
      @value = []
    end

    def add(obj1,obj2)
      @value << [obj1,obj2]
    end

    def serialize
      stack = super
      stack << self.write_7bit_encoded_int(self.size)
      self.value.each do |k,v|
        stack << k.serialize
        stack << v.serialize
      end 
      return stack
    end

    def to_xml
      xml = super
      xml.add_attribute("size",self.value.size.to_s)
      self.value.each do |k,v|
        pair = REXML::Element.new("Pair")
        key = REXML::Element.new("Key")
        key.add_element(k.to_xml)
        val = REXML::Element.new("Value")
        val.add_element(v.to_xml)
        pair.add_element(key)
        pair.add_element(val)
        xml.add_element(pair)
      end
      xml
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
miketracy-wwmd-0.2.11 lib/wwmd/viewstate/vs_hashtable.rb
miketracy-wwmd-0.2.12 lib/wwmd/viewstate/vs_hashtable.rb
miketracy-wwmd-0.2.14 lib/wwmd/viewstate/vs_hashtable.rb
miketracy-wwmd-0.2.15 lib/wwmd/viewstate/vs_hashtable.rb
miketracy-wwmd-0.2.16 lib/wwmd/viewstate/vs_hashtable.rb