Sha256: 7770178b777e86a3988a4c75801f0951fe109229c1cd7993066757ff794fcac2

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 Bytes

Contents

module Docks
  module Tags
    class Returns < Base
      def initialize
        @name = :returns
        @synonyms = [:return]
      end

      def process(symbol)
        symbol.update(@name) do |returns|
          returns = multiline_description(returns) do |first_line|
            first_line.strip!
            if match = first_line.match(/nothing\s*\-?\s*(?<description>.*)/i)
              { description: match[:description] }

            else
              match = first_line.match(/\{?(?<type>[^\}\-]*)\}?(?:\s*\-?\s*(?<description>.*))?/)
              {
                types: split_types(match[:type].strip),
                description: match[:description]
              }
            end
          end

          returns[:types] = nil if Array(returns[:types]).empty?
          OpenStruct.new(returns)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 lib/docks/tags/returns_tag.rb
docks_app-0.0.2 lib/docks/tags/returns_tag.rb
docks_app-0.0.1 lib/docks/tags/returns_tag.rb