Class: Object

Inherits:
BasicObject
Defined in:
lib/porolog/core_ext.rb

Overview

In Porolog, Objects represent atomic values.

Instance Method Summary collapse

Instance Method Details

#headtail?Boolean

Returns whether the Object is an Array with a head and a tail (for an Object, should be false).

Returns:

  • (Boolean)

    whether the Object is an Array with a head and a tail (for an Object, should be false).



48
49
50
# File 'lib/porolog/core_ext.rb', line 48

def headtail?
  false
end

#myidString

A convenience method for testing/debugging.

Returns:

  • (String)

    the equivalent of inspect.



16
17
18
# File 'lib/porolog/core_ext.rb', line 16

def myid
  inspect
end

#tail(other) ⇒ Array Also known as: /

Returns an Array with the Object being the head and the other Object being the tail.

Examples:

'head' / ['body', 'foot']   # ==> ['head', 'body', 'foot']
7.tail(:t)                  # ==> [7, *:t]

Parameters:

  • other (Object)

    the Object which is to be the tail

Returns:

  • (Array)

    an Array with the Object being the head and the other Object being the tail.



40
41
42
# File 'lib/porolog/core_ext.rb', line 40

def tail(other)
  [self]/other
end

#typeSymbol

Returns the type of the object (for an Object, should be :atomic)

Returns:

  • (Symbol)

    the type of the object (for an Object, should be :atomic)



26
27
28
# File 'lib/porolog/core_ext.rb', line 26

def type
  :atomic
end

#valueObject

Returns the value of the object, which is itself.

Returns:

  • (Object)

    the value of the object, which is itself.



31
32
33
# File 'lib/porolog/core_ext.rb', line 31

def value(*)
  self
end

#variablesArray

Returns embedded variables (for an Object, should be none).

Returns:

  • (Array)

    embedded variables (for an Object, should be none).



21
22
23
# File 'lib/porolog/core_ext.rb', line 21

def variables
  []
end