Module: Factbase::TermShared
Overview
TODO:
#302:30min Remove this module and move its methods to Factbase::TermBase. Currently, we use it because we are required to inject all thesse methods into Factbase::Term. When all the terms will inherit from Factbase::TermBase, we can remove this module.
This module provides shared methods for Factbase terms, including argument validation, symbol-based lookups, and handling of operand values.
Instance Method Summary collapse
-
#to_s ⇒ String
Turns it into a string.
Instance Method Details
#to_s ⇒ String
Turns it into a string.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/factbase/terms/shared.rb', line 14 def to_s @to_s ||= begin items = [] items << @op items += @operands.map do |o| if o.is_a?(String) "'#{o.gsub("'", "\\\\'").gsub('"', '\\\\"')}'" elsif o.is_a?(Time) o.utc.iso8601 else o.to_s end end "(#{items.join(' ')})" end end |