class SXP::Pair
Attributes
head[RW]
@return [Object]
tail[RW]
@return [Object]
Public Class Methods
new(head = nil, tail = nil)
click to toggle source
@param [Object] head @param [Object] tail
# File lib/sxp/pair.rb, line 13 def initialize(head = nil, tail = nil) @head, @tail = head, tail end
Public Instance Methods
dotted?()
click to toggle source
Returns `true` if the tail of this pair is not `nil` or another pair.
@return [Boolean] @see srfi.schemers.org/srfi-1/srfi-1.html#ImproperLists
# File lib/sxp/pair.rb, line 30 def dotted? !proper? end
empty?()
click to toggle source
Returns `true` if the head and tail of this pair are both `nil`.
@return [Boolean]
# File lib/sxp/pair.rb, line 21 def empty? head.nil? && tail.nil? end
inspect()
click to toggle source
Returns a developer-friendly representation of this pair.
@return [String]
# File lib/sxp/pair.rb, line 55 def inspect case when tail.nil? "(#{head.inspect})" else "(#{head.inspect} . #{tail.inspect})" end end
proper?()
click to toggle source
Returns `true` if the tail of this pair is `nil` or another pair.
@return [Boolean] @see srfi.schemers.org/srfi-1/srfi-1.html#ImproperLists
# File lib/sxp/pair.rb, line 39 def proper? tail.nil? || tail.is_a?(Pair) end
to_a()
click to toggle source
Returns an array representation of this pair.
@return [Array]
# File lib/sxp/pair.rb, line 47 def to_a [head, tail] end