Sha256: 63e18017f996053b7a0542a99bcb0d0f4da465683d4915d9d2971cf805aadf11

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

class Code
  class Object
    class Parameter < Object
      def initialize(*args, **_kargs, &)
        @raw = Dictionary.new(args.first.presence || {})
      end

      def code_name
        String.new(raw.code_get(String.new(:name)))
      end

      def code_regular?
        Boolean.new(raw.code_get(String.new(:regular?)))
      end

      def code_keyword?
        Boolean.new(raw.code_get(String.new(:keyword?)))
      end

      def code_regular_splat?
        Boolean.new(raw.code_get(String.new(:regular_splat?)))
      end

      def code_keyword_splat?
        Boolean.new(raw.code_get(String.new(:keyword_splat?)))
      end

      def code_default
        Code.new(raw.code_get(String.new(:default)))
      end

      def evaluate(...)
        default.evaluate(...)
      end

      def regular?
        code_regular?.truthy?
      end

      def keyword?
        code_keyword?.truthy?
      end

      def regular_splat?
        code_regular_splat?.truthy?
      end

      def keyword_splat?
        code_keyword_splat?.truthy?
      end

      def to_h
        raw.raw
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
code-ruby-1.1.3 lib/code/object/parameter.rb
code-ruby-1.1.1 lib/code/object/parameter.rb
code-ruby-1.1.0 lib/code/object/parameter.rb