Sha256: 607935db5c11d949d1951aa055755fa1d404be57b1bd5d54591ce3b86a56e4df

Contents?: true

Size: 913 Bytes

Versions: 20

Compression:

Stored size: 913 Bytes

Contents

# frozen_string_literal: true

module ApipieDSL
  class SeeDescription
    attr_reader :link, :description

    def initialize(method, options = {})
      @method = method
      @link = options[:link]
      @description = options[:desc] || options[:description]
      @scope = options[:scope]
    end

    def docs
      { link: link, url: see_url, description: description }
    end

    private

    def see_url
      method_description = if @scope
        if @scope.is_a?(ApipieDSL::ClassDescription)
          @scope.method_description(@method)
        else
          ApipieDSL.get_method_description(@scope.to_s, @method)
        end
      else
        ApipieDSL.get_method_description(@method)
      end
      raise ArgumentError, "Method #{@method} referenced in 'see' does not exist." if method_description.nil?

      method_description.doc_url(method_description.klass.sections.first)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
apipie-dsl-2.6.2 lib/apipie_dsl/see_description.rb
apipie-dsl-2.6.1 lib/apipie_dsl/see_description.rb
apipie-dsl-2.6.0 lib/apipie_dsl/see_description.rb
apipie-dsl-2.5.0 lib/apipie_dsl/see_description.rb
apipie-dsl-2.4.0 lib/apipie_dsl/see_description.rb
apipie-dsl-2.3.0 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.10 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.9 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.8 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.7 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.6 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.5 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.4 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.3 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.2 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.1 lib/apipie_dsl/see_description.rb
apipie-dsl-2.2.0 lib/apipie_dsl/see_description.rb
apipie-dsl-2.1.1 lib/apipie_dsl/see_description.rb
apipie-dsl-2.1.0 lib/apipie_dsl/see_description.rb
apipie-dsl-2.0.0 lib/apipie_dsl/see_description.rb