Class: Uinit::Sig::Parameter

Inherits:
Uinit::Struct
  • Object
show all
Defined in:
lib/uinit/sig/parameter.rb

Instance Method Summary collapse

Instance Method Details

#is!(value) ⇒ Object



47
48
49
50
51
# File 'lib/uinit/sig/parameter.rb', line 47

def is!(value)
  type.is!(value)
rescue Type::Error => e
  raise ParameterTypeError.new(self, e)
end

#opt?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/uinit/sig/parameter.rb', line 39

def opt?
  opt_arg? || opt_kwarg?
end

#opt_arg?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/uinit/sig/parameter.rb', line 19

def opt_arg?
  parameter_type == :opt
end

#opt_kwarg?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/uinit/sig/parameter.rb', line 31

def opt_kwarg?
  parameter_type == :key
end

#req_arg?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/uinit/sig/parameter.rb', line 15

def req_arg?
  parameter_type == :req
end

#req_kwarg?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/uinit/sig/parameter.rb', line 27

def req_kwarg?
  parameter_type == :keyreq
end

#rest_arg?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/uinit/sig/parameter.rb', line 23

def rest_arg?
  parameter_type == :rest
end

#rest_kwarg?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/uinit/sig/parameter.rb', line 35

def rest_kwarg?
  parameter_type == :keyrest
end

#typed?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/uinit/sig/parameter.rb', line 43

def typed?
  !type.nil?
end