Class: Code::Object::Parameter

Inherits:
Code::Object show all
Defined in:
lib/code/object/parameter.rb

Instance Attribute Summary collapse

Attributes inherited from Code::Object

#raw

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Code::Object

#<=>, #==, #as_json, call, #call, #code_and_operator, code_and_operator, code_different, #code_different, code_equal_equal, #code_equal_equal, code_equal_equal_equal, #code_equal_equal_equal, code_exclamation_point, #code_exclamation_point, #code_exclusive_range, code_exclusive_range, code_inclusive_range, #code_inclusive_range, code_new, code_or_operator, #code_or_operator, code_self, #code_self, #code_to_string, code_to_string, falsy?, #falsy?, #hash, inspect, #inspect, maybe, multi_fetch, #multi_fetch, repeat, sig, #sig, #to_json, to_s, #to_s, truthy?, #truthy?, |

Constructor Details

#initialize(*args, **_kargs, &_block) ⇒ Parameter

Returns a new instance of Parameter.



12
13
14
15
16
17
18
19
20
# File 'lib/code/object/parameter.rb', line 12

def initialize(*args, **_kargs, &_block)
  @raw = Dictionary.new(args.first.presence || {})
  @name = String.new(@raw.code_get(String.new(:name)))
  @keyword = Boolean.new(@raw.code_get(String.new(:keyword)))
  @regular_splat = Boolean.new(@raw.code_get(String.new(:regular_splat)))
  @keyword_splat = Boolean.new(@raw.code_get(String.new(:keyword_splat)))
  @default = Code.new(@raw.code_get(String.new(:default)))
  super
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



6
7
8
# File 'lib/code/object/parameter.rb', line 6

def default
  @default
end

#keywordObject (readonly)

Returns the value of attribute keyword.



6
7
8
# File 'lib/code/object/parameter.rb', line 6

def keyword
  @keyword
end

#keyword_splatObject (readonly)

Returns the value of attribute keyword_splat.



6
7
8
# File 'lib/code/object/parameter.rb', line 6

def keyword_splat
  @keyword_splat
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/code/object/parameter.rb', line 6

def name
  @name
end

#regular_splatObject (readonly)

Returns the value of attribute regular_splat.



6
7
8
# File 'lib/code/object/parameter.rb', line 6

def regular_splat
  @regular_splat
end

Class Method Details

.nameObject



8
9
10
# File 'lib/code/object/parameter.rb', line 8

def self.name
  "Parameter"
end

Instance Method Details

#evaluateObject



22
23
24
# File 'lib/code/object/parameter.rb', line 22

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

#keyword?Boolean

Returns:



30
31
32
# File 'lib/code/object/parameter.rb', line 30

def keyword?
  keyword.truthy?
end

#keyword_splat?Boolean

Returns:



38
39
40
# File 'lib/code/object/parameter.rb', line 38

def keyword_splat?
  keyword_splat.truthy?
end

#regular?Boolean

Returns:



26
27
28
# File 'lib/code/object/parameter.rb', line 26

def regular?
  !keyword?
end

#regular_splat?Boolean

Returns:



34
35
36
# File 'lib/code/object/parameter.rb', line 34

def regular_splat?
  regular_splat.truthy?
end