Class: RemLint::Vocabulary::Function
- Inherits:
-
Struct
- Object
- Struct
- RemLint::Vocabulary::Function
- Defined in:
- lib/remlint/vocabulary.rb
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #accepts?(count) ⇒ Boolean
-
#arity_description ⇒ Object
"1", "2 to 5", "at least 2" -- the phrasing an arity message needs.
- #variadic? ⇒ Boolean
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max
41 42 43 |
# File 'lib/remlint/vocabulary.rb', line 41 def max @max end |
#min ⇒ Object
Returns the value of attribute min
41 42 43 |
# File 'lib/remlint/vocabulary.rb', line 41 def min @min end |
#name ⇒ Object
Returns the value of attribute name
41 42 43 |
# File 'lib/remlint/vocabulary.rb', line 41 def name @name end |
Instance Method Details
#accepts?(count) ⇒ Boolean
46 47 48 |
# File 'lib/remlint/vocabulary.rb', line 46 def accepts?(count) count >= min && (variadic? || count <= max) end |
#arity_description ⇒ Object
"1", "2 to 5", "at least 2" -- the phrasing an arity message needs.
51 52 53 54 55 56 57 58 59 |
# File 'lib/remlint/vocabulary.rb', line 51 def arity_description if variadic? "at least #{min}" elsif min == max min.to_s else "#{min} to #{max}" end end |
#variadic? ⇒ Boolean
42 43 44 |
# File 'lib/remlint/vocabulary.rb', line 42 def variadic? max == Tables::NO_MAX_ARGS end |