def to_eeml(version = nil)
      if version.nil? || version == 5
        # Check that we have some data items
        if size < 1
          raise EEML::NoData.new('EEML requires at least one data item')
        end
        # Create EEML
        eeml = Builder::XmlMarkup.new
        eeml.instruct!
        eeml_options = {:xmlns => "http://www.eeml.org/xsd/005",
                        :'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
                        :'xsi:schemaLocation' => "http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd"}
        eeml_options[:version] = version if version
        eeml.eeml(eeml_options) do
          env_options = {}
          env_options[:updated] = @updated_at.xmlschema if @updated_at
          env_options[:creator] = @creator if @creator
          env_options[:id] = @id if @id
          eeml.environment(env_options) do |env|
            env.title @title if @title
            env.feed @feed if @feed
            env.status @status.to_s if @status
            env.description @description if @description
            env.icon @icon if @icon
            env.website @website if @website
            env.email @email if @email
            if @location
              loc_options = {}
              loc_options[:domain] = @location.domain
              loc_options[:exposure] = @location.exposure if @location.exposure
              loc_options[:disposition] = @location.disposition if @location.disposition
              env.location(loc_options) do |loc|
                loc.name @location.name if @location.name
                loc.lat @location.lat if @location.lat
                loc.lon @location.lon if @location.lon
                loc.ele @location.ele if @location.ele
              end
            end
            @data_items.each_index do |i|
              env.data(:id => @data_items[i].id || i) do |data|
                @data_items[i].tags.each do |tag|
                  data.tag tag
                end
                value_options = {}
                value_options[:maxValue] = @data_items[i].max_value if @data_items[i].max_value
                value_options[:minValue] = @data_items[i].min_value if @data_items[i].min_value
                data.value @data_items[i].value, value_options
                if @data_items[i].unit
                  unit_options = {}
                  unit_options[:symbol] = @data_items[i].unit.symbol if @data_items[i].unit.symbol
                  unit_options[:type] = @data_items[i].unit.type if @data_items[i].unit.type
                  data.unit @data_items[i].unit.name, unit_options
                end
              end
            end
          end
        end
      end
    end
def to_eeml(version = nil)
      if version.nil? || version == 5
        # Check that we have some data items
        if size < 1
          raise EEML::NoData.new('EEML requires at least one data item')
        end
        # Create EEML
        eeml = Builder::XmlMarkup.new
        eeml.instruct!
        eeml_options = {:xmlns => "http://www.eeml.org/xsd/005",
                        :'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
                        :'xsi:schemaLocation' => "http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd"}
        eeml_options[:version] = version if version
        eeml.eeml(eeml_options) do
          env_options = {}
          env_options[:updated] = @updated_at.xmlschema if @updated_at
          env_options[:creator] = @creator if @creator
          env_options[:id] = @id if @id
          eeml.environment(env_options) do |env|
            env.title @title if @title
            env.feed @feed if @feed
            env.status @status.to_s if @status
            env.description @description if @description
            env.icon @icon if @icon
            env.website @website if @website
            env.email @email if @email
            if @location
              loc_options = {}
              loc_options[:domain] = @location.domain
              loc_options[:exposure] = @location.exposure if @location.exposure
              loc_options[:disposition] = @location.disposition if @location.disposition
              env.location(loc_options) do |loc|
                loc.name @location.name if @location.name
                loc.lat @location.lat if @location.lat
                loc.lon @location.lon if @location.lon
                loc.ele @location.ele if @location.ele
              end
            end
            @data_items.each_index do |i|
              env.data(:id => @data_items[i].id || i) do |data|
                @data_items[i].tags.each do |tag|
                  data.tag tag
                end
                value_options = {}
                value_options[:maxValue] = @data_items[i].max_value if @data_items[i].max_value
                value_options[:minValue] = @data_items[i].min_value if @data_items[i].min_value
                data.value @data_items[i].value, value_options
                if @data_items[i].unit
                  unit_options = {}
                  unit_options[:symbol] = @data_items[i].unit.symbol if @data_items[i].unit.symbol
                  unit_options[:type] = @data_items[i].unit.type if @data_items[i].unit.type
                  data.unit @data_items[i].unit.name, unit_options
                end
              end
            end
          end
        end
      end
    end
Convert to EEML. Optional parameter describes the version of EEML to generate.
 Default (and currently only version implemented) is version 5.