Class: Pinspec::Param

Inherits:
Data
  • Object
show all
Defined in:
lib/pinspec/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#default_sourceObject (readonly)

Returns the value of attribute default_source

Returns:

  • (Object)

    the current value of default_source



18
19
20
# File 'lib/pinspec/types.rb', line 18

def default_source
  @default_source
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



18
19
20
# File 'lib/pinspec/types.rb', line 18

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



18
19
20
# File 'lib/pinspec/types.rb', line 18

def name
  @name
end

#type_hintObject (readonly)

Returns the value of attribute type_hint

Returns:

  • (Object)

    the current value of type_hint



18
19
20
# File 'lib/pinspec/types.rb', line 18

def type_hint
  @type_hint
end

Instance Method Details

#optional?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/pinspec/types.rb', line 23

def optional?
  OPTIONAL_PARAM_KINDS.include?(kind)
end

#positional?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/pinspec/types.rb', line 19

def positional?
  POSITIONAL_PARAM_KINDS.include?(kind)
end

#to_sObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/pinspec/types.rb', line 27

def to_s
  case kind
  when :req     then name.to_s
  when :opt     then "#{name} = #{default_source}"
  when :rest    then "*#{name}"
  when :keyreq  then "#{name}:"
  when :key     then "#{name}: #{default_source}"
  when :keyrest then "**#{name}"
  end
end