Class: Dry::Logic::Operations::Unary

Inherits:
Abstract
  • Object
show all
Defined in:
lib/dry/logic/operations/unary.rb

Direct Known Subclasses

Check, Each, Key, Negation

Instance Attribute Summary collapse

Attributes inherited from Abstract

#options, #rules

Instance Method Summary collapse

Methods inherited from Abstract

#curry, #id, #new, #to_ast, #with

Methods included from Dry::Logic::Operators

#and, #or, #then, #xor

Constructor Details

#initialize(*rules, **options) ⇒ Unary

Returns a new instance of Unary.



9
10
11
12
# File 'lib/dry/logic/operations/unary.rb', line 9

def initialize(*rules, **options)
  super
  @rule = rules.first
end

Instance Attribute Details

#ruleObject (readonly)

Returns the value of attribute rule.



7
8
9
# File 'lib/dry/logic/operations/unary.rb', line 7

def rule
  @rule
end

Instance Method Details

#ast(input = Undefined) ⇒ Object



14
15
16
# File 'lib/dry/logic/operations/unary.rb', line 14

def ast(input = Undefined)
  [type, rule.ast(input)]
end

#to_sObject



18
19
20
# File 'lib/dry/logic/operations/unary.rb', line 18

def to_s
  "#{type}(#{rule})"
end