Sha256: 176ab4fc60d6e7c22677084a2b1f71c58e382e16a7bac28ea0a16bc8188edede
Contents?: true
Size: 709 Bytes
Versions: 3
Compression:
Stored size: 709 Bytes
Contents
# frozen_string_literal: true module PrologMQI class Term def initialize(term) @term = term end def functor? @term.is_a?(Hash) && @term.key?('functor') && @term.key?('args') end def array? @term.is_a?(Array) end def variable? @term.is_a?(String) && (@term[0].upcase == @term[0] || @term.start_with?('_')) end def atom? @term.is_a?(String) && !variable? end def name return @term if atom? || variable? @term['functor'] end def args @term['args'].map do |arg| next nil if arg == 'nil' next arg.to_i if arg.is_a?(String) && arg.to_i.to_s == arg arg end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
prolog_mqi-0.1.3 | lib/prolog_mqi/term.rb |
prolog_mqi-0.1.2 | lib/prolog_mqi/term.rb |
prolog_mqi-0.1.1 | lib/prolog_mqi/term.rb |