Module: Factbase::Meta
- Included in:
- Term
- Defined in:
- lib/factbase/terms/meta.rb
Overview
Meta terms.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #absent(fact, _maps, _fb) ⇒ Object
- #exists(fact, _maps, _fb) ⇒ Object
-
#many(fact, maps, fb) ⇒ Object
The property has many (more than one) values.
- #nil(fact, maps, fb) ⇒ Object
-
#one(fact, maps, fb) ⇒ Object
The property has exactly one value.
- #size(fact, _maps, _fb) ⇒ Object
- #type(fact, _maps, _fb) ⇒ Object
Instance Method Details
#absent(fact, _maps, _fb) ⇒ Object
19 20 21 22 |
# File 'lib/factbase/terms/meta.rb', line 19 def absent(fact, _maps, _fb) assert_args(1) _by_symbol(0, fact).nil? end |
#exists(fact, _maps, _fb) ⇒ Object
14 15 16 17 |
# File 'lib/factbase/terms/meta.rb', line 14 def exists(fact, _maps, _fb) assert_args(1) !_by_symbol(0, fact).nil? end |
#many(fact, maps, fb) ⇒ Object
The property has many (more than one) values.
46 47 48 49 50 |
# File 'lib/factbase/terms/meta.rb', line 46 def many(fact, maps, fb) assert_args(1) v = _values(0, fact, maps, fb) !v.nil? && v.size > 1 end |
#nil(fact, maps, fb) ⇒ Object
40 41 42 43 |
# File 'lib/factbase/terms/meta.rb', line 40 def nil(fact, maps, fb) assert_args(1) _values(0, fact, maps, fb).nil? end |
#one(fact, maps, fb) ⇒ Object
The property has exactly one value.
53 54 55 56 57 |
# File 'lib/factbase/terms/meta.rb', line 53 def one(fact, maps, fb) assert_args(1) v = _values(0, fact, maps, fb) !v.nil? && v.size == 1 end |
#size(fact, _maps, _fb) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/factbase/terms/meta.rb', line 24 def size(fact, _maps, _fb) assert_args(1) v = _by_symbol(0, fact) return 0 if v.nil? return 1 unless v.respond_to?(:to_a) v.size end |
#type(fact, _maps, _fb) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/factbase/terms/meta.rb', line 32 def type(fact, _maps, _fb) assert_args(1) v = _by_symbol(0, fact) return 'nil' if v.nil? v = v[0] if v.respond_to?(:each) && v.size == 1 v.class.to_s end |