Sha256: 9620e98485c2892cc80f35a86093d4dd092f80232de1c03d51fdf9deaa77eb76

Contents?: true

Size: 1.07 KB

Versions: 29

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

class Code
  class Node
    class FunctionParameter < Node
      def initialize(parsed)
        return if parsed.blank?

        @name = parsed.delete(:name).presence
        @keyword = parsed.delete(:keyword).present?
      end

      def name
        Object::String.new(@name)
      end

      def regular?
        !@keyword
      end

      def keyword?
        !!@keyword
      end

      def regular_splat?
        false
      end

      def keyword_splat?
        false
      end

      def default
        nil
      end

      def to_h
        {
          Object::String.new(:name) => Object::String.new(name),
          Object::String.new(:regular?) => Object::Boolean.new(regular?),
          Object::String.new(:keyword?) => Object::Boolean.new(keyword?),
          Object::String.new(:regular_splat?) =>
            Object::Boolean.new(regular_splat?),
          Object::String.new(:keyword_splat?) =>
            Object::Boolean.new(keyword_splat?),
          Object::String.new(:default) => Object::Code.new(default)
        }
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
code-ruby-1.1.3 lib/code/node/function_parameter.rb
code-ruby-1.1.1 lib/code/node/function_parameter.rb
code-ruby-1.1.0 lib/code/node/function_parameter.rb
code-ruby-1.0.0 lib/code/node/function_parameter.rb
code-ruby-0.15.16 lib/code/node/function_parameter.rb
code-ruby-0.15.15 lib/code/node/function_parameter.rb
code-ruby-0.15.14 lib/code/node/function_parameter.rb
code-ruby-0.15.13 lib/code/node/function_parameter.rb
code-ruby-0.15.12 lib/code/node/function_parameter.rb
code-ruby-0.15.11 lib/code/node/function_parameter.rb
code-ruby-0.15.10 lib/code/node/function_parameter.rb
code-ruby-0.15.9 lib/code/node/function_parameter.rb
code-ruby-0.15.8 lib/code/node/function_parameter.rb
code-ruby-0.15.7 lib/code/node/function_parameter.rb
code-ruby-0.15.6 lib/code/node/function_parameter.rb
code-ruby-0.15.5 lib/code/node/function_parameter.rb
code-ruby-0.15.4 lib/code/node/function_parameter.rb
code-ruby-0.15.3 lib/code/node/function_parameter.rb
code-ruby-0.15.2 lib/code/node/function_parameter.rb
code-ruby-0.15.0 lib/code/node/function_parameter.rb