Class: SXP::Pair
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#dotted? ⇒ Boolean
Returns
true
if the tail of this pair is notnil
or another pair. -
#empty? ⇒ Boolean
Returns
true
if the head and tail of this pair are bothnil
. -
#initialize(head = nil, tail = nil) ⇒ Pair
constructor
A new instance of Pair.
-
#inspect ⇒ String
Returns a developer-friendly representation of this pair.
-
#proper? ⇒ Boolean
Returns
true
if the tail of this pair isnil
or another pair. -
#to_a ⇒ Array
Returns an array representation of this pair.
Constructor Details
#initialize(head = nil, tail = nil) ⇒ Pair
Returns a new instance of Pair.
14 15 16 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 14 def initialize(head = nil, tail = nil) @head, @tail = head, tail end |
Instance Attribute Details
#head ⇒ Object
6 7 8 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 6 def head @head end |
#tail ⇒ Object
9 10 11 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 9 def tail @tail end |
Instance Method Details
#dotted? ⇒ Boolean
Returns true
if the tail of this pair is not nil
or another pair.
31 32 33 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 31 def dotted? !proper? end |
#empty? ⇒ Boolean
Returns true
if the head and tail of this pair are both nil
.
22 23 24 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 22 def empty? head.nil? && tail.nil? end |
#inspect ⇒ String
Returns a developer-friendly representation of this pair.
56 57 58 59 60 61 62 63 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 56 def inspect case when tail.nil? "(#{head.inspect})" else "(#{head.inspect} . #{tail.inspect})" end end |
#proper? ⇒ Boolean
Returns true
if the tail of this pair is nil
or another pair.
40 41 42 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 40 def proper? tail.nil? || tail.is_a?(Pair) end |
#to_a ⇒ Array
Returns an array representation of this pair.
48 49 50 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/pair.rb', line 48 def to_a [head, tail] end |