Class: Furud::Functions::Entry
- Inherits:
-
Struct
- Object
- Struct
- Furud::Functions::Entry
- Defined in:
- lib/furud/functions.rb,
sig/furud.rbs
Constant Summary collapse
- ERROR_HANDLERS =
%w[IF IFERROR IFNA FILTER COUNTIF COUNTIFS SUMIF SUMIFS AVERAGEIF AVERAGEIFS].freeze
Instance Attribute Summary collapse
-
#arity ⇒ Object
Returns the value of attribute arity.
-
#implementation ⇒ Object
Returns the value of attribute implementation.
-
#name ⇒ Object
Returns the value of attribute name.
-
#volatile ⇒ Object
Returns the value of attribute volatile.
Instance Method Summary collapse
Instance Attribute Details
#arity ⇒ Object
Returns the value of attribute arity
9 10 11 |
# File 'lib/furud/functions.rb', line 9 def arity @arity end |
#implementation ⇒ Object
Returns the value of attribute implementation
9 10 11 |
# File 'lib/furud/functions.rb', line 9 def implementation @implementation end |
#name ⇒ Object
Returns the value of attribute name
9 10 11 |
# File 'lib/furud/functions.rb', line 9 def name @name end |
#volatile ⇒ Object
Returns the value of attribute volatile
9 10 11 |
# File 'lib/furud/functions.rb', line 9 def volatile @volatile end |
Instance Method Details
#accepts?(count) ⇒ Boolean
28 |
# File 'lib/furud/functions.rb', line 28 def accepts?(count) = arity_match?(count) |
#call(*args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/furud/functions.rb', line 12 def call(*args) return ErrorValue.new(code: :value) unless arity_match?(args.length) unless handles_errors? error = args.lazy.map { |value| first_error(value) }.find(&:itself) return error if error end implementation.call(*args) rescue ZeroDivisionError ErrorValue.new(code: :div0) rescue Math::DomainError, RangeError ErrorValue.new(code: :num) rescue ArgumentError, TypeError, FloatDomainError ErrorValue.new(code: :value) end |