Sha256: d0d1dc90cb020ef8e032633a38eac8cece7513f4c0a5002db2c0a37c42e1a230

Contents?: true

Size: 997 Bytes

Versions: 35

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

module Renalware
  module UKRDC
    module Outgoing
      module Rendering
        class Base
          protected

          def create_node(name, value = nil)
            elem = Ox::Element.new(name.to_s)
            elem << value.to_s if value.present?
            yield(elem) if block_given?
            elem
          end

          # Example output:
          #   "123 approx" => 123
          #   "123" => 123
          #   123 => 123
          #   123.1 => 123
          #   0 => nil
          #   "n/a" => nil
          def coerce_to_integer(value)
            value.to_i > 0 && value.presence&.to_i
          end

          # Example output:
          #   "123 approx" => 123.0
          #   "123" => 123.0
          #   123 => 123.0
          #   123.1 => 123.1
          #   0 => nil
          #   "n/a" => nil
          def coerce_to_float(value)
            value.to_f > 0.0 && value.presence&.to_f
          end
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.1.0 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.167 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.166 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.165 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.164 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.163 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.162 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.161 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.160 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.159 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.158 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.157 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.156 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.155 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.153 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.152 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.151 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.149 app/models/renalware/ukrdc/outgoing/rendering/base.rb
renalware-core-2.0.148 app/models/renalware/ukrdc/outgoing/rendering/base.rb