Sha256: 6d56d03ae8e7d1fb3081cdb34ea788f1387f35b0c57c8889812f760c01271d8f

Contents?: true

Size: 609 Bytes

Versions: 20

Compression:

Stored size: 609 Bytes

Contents

module Spyke
  class RfcConverter
    def initialize(input)
      @input = input
    end

    def convert
      output = @input.dup
      output = wrap_required_variables_in_curly_braces(output)
      output = convert_parens_to_curly_braces(output)
      output = remove_colons(output)
      output
    end

    private
      def wrap_required_variables_in_curly_braces(text)
        text.gsub(/(:\w+(?!\)))\b/, '{\1}')
      end

      def convert_parens_to_curly_braces(text)
        text.gsub('(', '{').gsub(')', '}')
      end

      def remove_colons(text)
        text.gsub(':', '')
      end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
spyke-7.2.2 lib/spyke/rfc_converter.rb
spyke-7.1.1 lib/spyke/rfc_converter.rb
spyke-7.1.0 lib/spyke/rfc_converter.rb
spyke-7.0.0 lib/spyke/rfc_converter.rb
spyke-6.1.3 lib/spyke/rfc_converter.rb
spyke-6.1.2 lib/spyke/rfc_converter.rb
spyke-6.1.1 lib/spyke/rfc_converter.rb
spyke-6.1.0 lib/spyke/rfc_converter.rb
spyke-6.0.0 lib/spyke/rfc_converter.rb
spyke-5.4.3 lib/spyke/rfc_converter.rb
spyke-5.4.2 lib/spyke/rfc_converter.rb
spyke-5.4.1 lib/spyke/rfc_converter.rb
spyke-5.4.0 lib/spyke/rfc_converter.rb
spyke-5.3.4 lib/spyke/rfc_converter.rb
spyke-5.3.3 lib/spyke/rfc_converter.rb
spyke-5.3.2 lib/spyke/rfc_converter.rb
spyke-5.3.1 lib/spyke/rfc_converter.rb
spyke-5.3.0 lib/spyke/rfc_converter.rb
spyke-5.2.0 lib/spyke/rfc_converter.rb
spyke-5.1.0 lib/spyke/rfc_converter.rb