Class: DuckTesting::YARD::MethodParameter
- Inherits:
-
Object
- Object
- DuckTesting::YARD::MethodParameter
- Defined in:
- lib/duck_testing/yard/method_parameter.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#method_object ⇒ Object
readonly
Returns the value of attribute method_object.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameter_tag ⇒ Object
readonly
Returns the value of attribute parameter_tag.
Instance Method Summary collapse
- #documented? ⇒ Boolean
- #expected_types ⇒ Array<DuckTesting::Type::Base>
-
#initialize(method_object, name, default, parameter_tag) ⇒ MethodParameter
constructor
A new instance of MethodParameter.
- #key_name ⇒ Symbol?
- #keyword? ⇒ Boolean
- #to_s ⇒ String
Constructor Details
#initialize(method_object, name, default, parameter_tag) ⇒ MethodParameter
Returns a new instance of MethodParameter.
10 11 12 13 14 15 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 10 def initialize(method_object, name, default, parameter_tag) @method_object = method_object @name = name @default = default @parameter_tag = parameter_tag end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
4 5 6 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 4 def default @default end |
#method_object ⇒ Object (readonly)
Returns the value of attribute method_object.
4 5 6 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 4 def method_object @method_object end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 4 def name @name end |
#parameter_tag ⇒ Object (readonly)
Returns the value of attribute parameter_tag.
4 5 6 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 4 def parameter_tag @parameter_tag end |
Instance Method Details
#documented? ⇒ Boolean
29 30 31 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 29 def documented? !parameter_tag.nil? end |
#expected_types ⇒ Array<DuckTesting::Type::Base>
44 45 46 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 44 def expected_types parameter_tag ? DuckTesting::YARD.expected_types(parameter_tag.types) : [] end |
#key_name ⇒ Symbol?
39 40 41 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 39 def key_name keyword? ? name[0...-1].to_sym : nil end |
#keyword? ⇒ Boolean
34 35 36 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 34 def keyword? name.end_with?(":") end |
#to_s ⇒ String
18 19 20 21 22 23 24 25 26 |
# File 'lib/duck_testing/yard/method_parameter.rb', line 18 def to_s if default.nil? name elsif name.end_with?(":") "#{name} #{default}" else "#{name} = #{default}" end end |