Sha256: cb0230563ad863bbdddfb4247e99c9709864d54405d709d654749fda41eab8a8

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require 'puppet-strings/markdown/base'

module PuppetStrings::Markdown
  class Function < Base
    attr_reader :signatures

    def initialize(registry)
      @template = 'function.erb'
      super(registry, 'function')
      @signatures = []
      registry[:signatures].each do |sig|
        @signatures.push(Signature.new(sig))
      end
    end

    def render
      super(@template)
    end

    def type
      t = @registry[:type]
      if t =~ /ruby4x/
        "Ruby 4.x API"
      elsif t =~ /ruby3/
        "Ruby 3.x API"
      elsif t =~ /ruby/
        "Ruby"
      else
        "Puppet Language"
      end
    end

    def error_type(r) # rubocop:disable Naming/UncommunicativeMethodParamName
      "`#{r.split(' ')[0]}`"
    end

    def error_text(r) # rubocop:disable Naming/UncommunicativeMethodParamName
      "#{r.split(' ').drop(1).join(' ')}"
    end
  end

  class Function::Signature < Base
    def initialize(registry)
      @registry = registry
      super(@registry, 'function signature')
    end

    def signature
      @registry[:signature]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-strings-2.5.0 lib/puppet-strings/markdown/function.rb
puppet-strings-2.4.0 lib/puppet-strings/markdown/function.rb
puppet-strings-2.3.1 lib/puppet-strings/markdown/function.rb
puppet-strings-2.3.0 lib/puppet-strings/markdown/function.rb