Class: Pinspec::Param
- Inherits:
-
Data
- Object
- Data
- Pinspec::Param
- Defined in:
- lib/pinspec/types.rb
Instance Attribute Summary collapse
-
#default_source ⇒ Object
readonly
Returns the value of attribute default_source.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type_hint ⇒ Object
readonly
Returns the value of attribute type_hint.
Instance Method Summary collapse
Instance Attribute Details
#default_source ⇒ Object (readonly)
Returns the value of attribute default_source
18 19 20 |
# File 'lib/pinspec/types.rb', line 18 def default_source @default_source end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind
18 19 20 |
# File 'lib/pinspec/types.rb', line 18 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name
18 19 20 |
# File 'lib/pinspec/types.rb', line 18 def name @name end |
#type_hint ⇒ Object (readonly)
Returns the value of attribute type_hint
18 19 20 |
# File 'lib/pinspec/types.rb', line 18 def type_hint @type_hint end |
Instance Method Details
#optional? ⇒ Boolean
23 24 25 |
# File 'lib/pinspec/types.rb', line 23 def optional? OPTIONAL_PARAM_KINDS.include?(kind) end |
#positional? ⇒ Boolean
19 20 21 |
# File 'lib/pinspec/types.rb', line 19 def positional? POSITIONAL_PARAM_KINDS.include?(kind) end |
#to_s ⇒ Object
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 |