lib/sycamore/nothing.rb in metaractor-sycamore-0.4.2 vs lib/sycamore/nothing.rb in metaractor-sycamore-0.4.3
- old
+ new
@@ -1,9 +1,8 @@
-require 'singleton'
+require "singleton"
module Sycamore
-
##
# The Nothing Tree singleton class.
#
# The Nothing Tree is an empty Sycamore Tree, and means "there are no nodes".
#
@@ -41,11 +40,11 @@
########################################################################
# TODO: YARD should be informed about this method definitions.
command_methods.each do |command_method|
define_method command_method do |*args|
- raise NothingMutation, 'attempt to change the Nothing tree'
+ raise NothingMutation, "attempt to change the Nothing tree"
end
end
# TODO: YARD should be informed about this method definitions.
pure_destructive_command_methods.each do |command_method|
@@ -64,20 +63,20 @@
# A string representation of the Nothing tree.
#
# @return [String]
#
def to_s
- 'Tree[Nothing]'
+ "Tree[Nothing]"
end
##
# A developer-friendly string representation of the Nothing tree.
#
# @return [String]
#
def inspect
- '#<Sycamore::Nothing>'
+ "#<Sycamore::Nothing>"
end
def freeze
super
end
@@ -93,11 +92,10 @@
#
def ==(other)
(other.is_a?(Tree) or other.is_a?(Absence)) and other.empty?
end
-
########################################################################
# Falsiness
#
# Sadly, in Ruby we can't do that match to reach this goal.
#
@@ -117,11 +115,10 @@
# def nil?
# true
# end
-
########################################################################
# Some helpers
#
# Ideally these would be implemented with Refinements, but since they
# aren't available anywhere (I'm looking at you, JRuby), we have to be
@@ -137,21 +134,19 @@
# @api private
class NestedStringPresentation
include Singleton
def inspect
- 'n/a'
+ "n/a"
end
end
##
# @api private
NestedString = NestedStringPresentation.instance.freeze
-
end
############################################################################
# The Nothing Tree Singleton object
#
Nothing = NothingTree.instance.freeze
-
end