Module: Factbase::Casting
- Included in:
- Term
- Defined in:
- lib/factbase/terms/casting.rb
Overview
Casting terms.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #to_float(fact, maps, fb) ⇒ Object
- #to_integer(fact, maps, fb) ⇒ Object
- #to_string(fact, maps, fb) ⇒ Object
- #to_time(fact, maps, fb) ⇒ Object
Instance Method Details
#to_float(fact, maps, fb) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/factbase/terms/casting.rb', line 28 def to_float(fact, maps, fb) assert_args(1) vv = _values(0, fact, maps, fb) return nil if vv.nil? vv[0].to_f end |
#to_integer(fact, maps, fb) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/factbase/terms/casting.rb', line 21 def to_integer(fact, maps, fb) assert_args(1) vv = _values(0, fact, maps, fb) return nil if vv.nil? vv[0].to_i end |
#to_string(fact, maps, fb) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/factbase/terms/casting.rb', line 14 def to_string(fact, maps, fb) assert_args(1) vv = _values(0, fact, maps, fb) return nil if vv.nil? vv[0].to_s end |
#to_time(fact, maps, fb) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/factbase/terms/casting.rb', line 35 def to_time(fact, maps, fb) assert_args(1) vv = _values(0, fact, maps, fb) return nil if vv.nil? Time.parse(vv[0].to_s) end |