Class: RemLint::Vocabulary::Function

Inherits:
Struct
  • Object
show all
Defined in:
lib/remlint/vocabulary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#maxObject

Returns the value of attribute max

Returns:

  • (Object)

    the current value of max



41
42
43
# File 'lib/remlint/vocabulary.rb', line 41

def max
  @max
end

#minObject

Returns the value of attribute min

Returns:

  • (Object)

    the current value of min



41
42
43
# File 'lib/remlint/vocabulary.rb', line 41

def min
  @min
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



41
42
43
# File 'lib/remlint/vocabulary.rb', line 41

def name
  @name
end

Instance Method Details

#accepts?(count) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/remlint/vocabulary.rb', line 46

def accepts?(count)
  count >= min && (variadic? || count <= max)
end

#arity_descriptionObject

"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

Returns:

  • (Boolean)


42
43
44
# File 'lib/remlint/vocabulary.rb', line 42

def variadic?
  max == Tables::NO_MAX_ARGS
end