Sha256: e74a65fa941f465fc954ecf28198effdc82ad6a04ea25d780abb9e1413c0fa38

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

module Flexparser
  #
  # Class to build handle turn a given object into
  # a Fragment. Used mostly as a Safeguard.
  #
  class FragmentBuilder
    class << self
      #
      # @param str [String|Fragment] The object that will be turned into
      #   a Fragment.
      # @return A fragment of some kind. Either the given fragment, a new
      #   normal {Fragment} or en {EmptyFragment}.
      #
      def build(str, namespaces: {})
        return str if str.is_a?(Fragment)
        return EmptyFragment.new(str) if str.nil?
        Fragment.new(str, namespaces: namespaces)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flexparser-1.0.3 lib/flexparser/fragment_builder.rb