Class: Code::Node::RegularFunctionArgument

Inherits:
Code::Node
  • Object
show all
Defined in:
lib/code/node/regular_function_argument.rb

Instance Method Summary collapse

Constructor Details

#initialize(argument) ⇒ RegularFunctionArgument

Returns a new instance of RegularFunctionArgument.



4
5
6
7
8
9
10
11
12
13
# File 'lib/code/node/regular_function_argument.rb', line 4

def initialize(argument)
  @block = argument.key?(:block)
  @splat = argument.key?(:splat)
  @keyword_splat = argument.key?(:keyword_splat)
  @name = argument.fetch(:name)

  if argument.key?(:default)
    @default = ::Code::Node::Code.new(argument.fetch(:default))
  end
end

Instance Method Details

#block?Boolean

Returns:



31
32
33
# File 'lib/code/node/regular_function_argument.rb', line 31

def block?
  @block
end

#evaluate(**args) ⇒ Object



15
16
17
# File 'lib/code/node/regular_function_argument.rb', line 15

def evaluate(**args)
  @default ? @default.evaluate(**args) : ::Code::Object::Nothing.new
end

#keyword_splat?Boolean

Returns:



27
28
29
# File 'lib/code/node/regular_function_argument.rb', line 27

def keyword_splat?
  @keyword_splat
end

#nameObject



19
20
21
# File 'lib/code/node/regular_function_argument.rb', line 19

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

#splat?Boolean

Returns:



23
24
25
# File 'lib/code/node/regular_function_argument.rb', line 23

def splat?
  @splat
end