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



9
10
11
# File 'lib/pinspec/types.rb', line 9

def default_source
  @default_source
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



9
10
11
# File 'lib/pinspec/types.rb', line 9

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



9
10
11
# File 'lib/pinspec/types.rb', line 9

def name
  @name
end

#type_hintObject (readonly)

Returns the value of attribute type_hint

Returns:

  • (Object)

    the current value of type_hint



9
10
11
# File 'lib/pinspec/types.rb', line 9

def type_hint
  @type_hint
end

Instance Method Details

#optional?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/pinspec/types.rb', line 14

def optional?
  OPTIONAL_PARAM_KINDS.include?(kind)
end

#positional?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/pinspec/types.rb', line 10

def positional?
  POSITIONAL_PARAM_KINDS.include?(kind)
end

#to_sObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/pinspec/types.rb', line 18

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