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:

  • 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

#myid ⇒ String

A convenience method for testing/debugging.

Returns:

  • 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:

  • the Object which is to be the tail

Returns:

  • 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

#type ⇒ Symbol

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

Returns:

  • 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

#value ⇒ Object

Returns the value of the object, which is itself.

Returns:

  • the value of the object, which is itself.



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

def value(*)
  self
end

#variables ⇒ Array

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

Returns:

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



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

def variables
  []
end