Class: Upl::Functor
Overview
Just an idea, not used yet.
Instance Attribute Summary collapse
-
#atom ⇒ Object
readonly
Returns the value of attribute atom.
Instance Method Summary collapse
- #args ⇒ Object
- #arity ⇒ Object
-
#functor_t ⇒ Object
create a functor_t pointer.
-
#initialize(atom, args_or_arity) ⇒ Functor
constructor
A new instance of Functor.
-
#predicate_t ⇒ Object
create a predicate_t.
- #pretty_print(pp) ⇒ Object
Constructor Details
#initialize(atom, args_or_arity) ⇒ Functor
Returns a new instance of Functor.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/upl/functor.rb', line 4 def initialize( atom, args_or_arity ) @atom = atom case args_or_arity when Array @args = args_or_arity @arity = args.size when Integer @arity = args_or_arity else "dunno bout #{args_or_arity.inspect}" end end |
Instance Attribute Details
#atom ⇒ Object (readonly)
Returns the value of attribute atom.
18 19 20 |
# File 'lib/upl/functor.rb', line 18 def atom @atom end |
Instance Method Details
#args ⇒ Object
19 |
# File 'lib/upl/functor.rb', line 19 def args; @args || [] end |
#arity ⇒ Object
20 |
# File 'lib/upl/functor.rb', line 20 def arity; @arity || args.size end |
#functor_t ⇒ Object
create a functor_t pointer
23 24 25 |
# File 'lib/upl/functor.rb', line 23 def functor_t raise NotImplementedError end |
#predicate_t ⇒ Object
create a predicate_t
28 29 30 |
# File 'lib/upl/functor.rb', line 28 def predicate_t raise NotImplementedError end |
#pretty_print(pp) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/upl/functor.rb', line 32 def pretty_print(pp) unless atom.to_sym == :',' pp.text atom.to_s if arity > 0 pp.text ?/ pp.text arity.to_s end end if arity > 0 pp.group 1, ?(, ?) do args.each_with_index do |ruby_term,i| ruby_term.pretty_print pp pp.text ?, if i < arity - 1 end end end end |