Sha256: 2f0332ec63eb92f33a407c8c0e47a074e1eee6d0b27115bc169547aabadf985a

Contents?: true

Size: 552 Bytes

Versions: 3

Compression:

Stored size: 552 Bytes

Contents

# frozen_string_literal: true

module Marameters
  # Builds a method's parameter signature.
  class Signature
    def initialize parameters, builder: Signatures::Builder.new
      @parameters = parameters
      @builder = builder
      freeze
    end

    def to_s = parameters == :all ? "..." : build.join(", ")

    alias to_str to_s

    private

    attr_reader :parameters, :builder

    def build
      parameters.reduce [] do |signature, (kind, name, default)|
        signature << builder.call(kind, name, default:)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marameters-4.1.0 lib/marameters/signature.rb
marameters-4.0.1 lib/marameters/signature.rb
marameters-4.0.0 lib/marameters/signature.rb