Module: Factbase::Term::Casting
- Included in:
- Factbase::Term
- Defined in:
- lib/factbase/terms/casting.rb
Overview
Casting terms.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #to_float(fact, maps) ⇒ Object
- #to_integer(fact, maps) ⇒ Object
- #to_string(fact, maps) ⇒ Object
- #to_time(fact, maps) ⇒ Object
Instance Method Details
#to_float(fact, maps) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/factbase/terms/casting.rb', line 45 def to_float(fact, maps) assert_args(1) vv = the_values(0, fact, maps) return nil if vv.nil? vv[0].to_f end |
#to_integer(fact, maps) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/factbase/terms/casting.rb', line 38 def to_integer(fact, maps) assert_args(1) vv = the_values(0, fact, maps) return nil if vv.nil? vv[0].to_i end |
#to_string(fact, maps) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/factbase/terms/casting.rb', line 31 def to_string(fact, maps) assert_args(1) vv = the_values(0, fact, maps) return nil if vv.nil? vv[0].to_s end |
#to_time(fact, maps) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/factbase/terms/casting.rb', line 52 def to_time(fact, maps) assert_args(1) vv = the_values(0, fact, maps) return nil if vv.nil? Time.parse(vv[0].to_s) end |