Sha256: 0f848d0a0f8a8e83d6175f5c1429f0b1f3607ea53ae67e9d18bcc070c85569bb

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 Bytes

Contents

# frozen_string_literal: true

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

      def code_name
        String.new(raw.code_get(String.new(:name)))
      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?
        !keyword?
      end

      def keyword?
        code_keyword.truthy?
      end

      def regular_splat?
        code_regular_splat.truthy?
      end

      def keyword_splat?
        code_keyword_splat.truthy?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
code-ruby-0.13.1 lib/code/object/parameter.rb
code-ruby-0.13.0 lib/code/object/parameter.rb