Sha256: be2e5b63b51d9d8d2bcbf1e0898d62c3829b35a653730e84cce2f4fefa8ac23a

Contents?: true

Size: 770 Bytes

Versions: 6

Compression:

Stored size: 770 Bytes

Contents

module Metacrunch
  class SNR
    class Section
      class Field

        attr_reader   :name
        attr_accessor :value

        def initialize(name, value)
          raise ArgumentError, "required Field#name not given" if name.nil?

          @name  = name
          @value = value
        end

        # ------------------------------------------------------------------------------
        # Serialization
        # ------------------------------------------------------------------------------

        def to_xml(builder)
          if value.respond_to?(:to_xml)
            value.to_xml(root: self.name, builder: builder, skip_instruct: true)
          else
            builder.tag!(self.name, self.value)
          end
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
metacrunch-2.2.3 lib/metacrunch/snr/field.rb
metacrunch-2.2.2 lib/metacrunch/snr/field.rb
metacrunch-2.2.1 lib/metacrunch/snr/field.rb
metacrunch-2.2.0 lib/metacrunch/snr/field.rb
metacrunch-2.1.1 lib/metacrunch/snr/field.rb
metacrunch-2.1.0 lib/metacrunch/snr/field.rb