Class: Porolog::Tail
Overview
A Porolog::Tail is used to represent the tail of a list.
It corresponds to the use of the splat operator within an Array.
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of the Tail.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether the value of the Tail is equal to the value of another Object.
-
#initialize(value = UNKNOWN_TAIL) ⇒ Tail
constructor
Creates a new Tail for an Array.
-
#inspect ⇒ String
Pretty representation.
-
#type ⇒ Symbol
The type of the Tail, which should be :tail.
-
#variables ⇒ Array
Embedded variables.
Constructor Details
#initialize(value = UNKNOWN_TAIL) ⇒ Tail
Creates a new Tail for an Array.
22 23 24 |
# File 'lib/porolog/tail.rb', line 22 def initialize(value = UNKNOWN_TAIL) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of the Tail. The optional arguments are ignored; this is for polymorphic compatibility with Porolog::Value and Porolog::Variable, which are used to prevent inifinite recursion.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/porolog/tail.rb', line 18 class Tail # Creates a new Tail for an Array. # @param value [Object] the value of the tail. def initialize(value = UNKNOWN_TAIL) @value = value end # @return [Symbol] the type of the Tail, which should be :tail. def type :tail end # Returns the value of the Tail. # The optional arguments are ignored; this is for polymorphic compatibility with Porolog::Value and Porolog::Variable, # which are used to prevent inifinite recursion. # @return [Object] the value of the Tail. def value(*) @value end # @return [String] pretty representation. def inspect "*#{@value.inspect}" end # @return [Array] embedded variables. def variables @value.variables end # @param other [Object, #value] # @return [Boolean] whether the value of the Tail is equal to the value of another Object. def ==(other) @value == other.value end end |
Instance Method Details
#==(other) ⇒ Boolean
51 52 53 |
# File 'lib/porolog/tail.rb', line 51 def ==(other) @value == other.value end |
#inspect ⇒ String
40 41 42 |
# File 'lib/porolog/tail.rb', line 40 def inspect "*#{@value.inspect}" end |
#type ⇒ Symbol
27 28 29 |
# File 'lib/porolog/tail.rb', line 27 def type :tail end |
#variables ⇒ Array
45 46 47 |
# File 'lib/porolog/tail.rb', line 45 def variables @value.variables end |