Class: Code::Object::Nothing
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Nothing
- Defined in:
- lib/code/object/nothing.rb
Constant Summary collapse
- CLASS_DOCUMENTATION =
{ name: "Nothing", description: "represents no value.", examples: %w[nothing Nothing.new Nothing.new(1)] }.freeze
- INSTANCE_FUNCTIONS =
{ "empty?" => { name: "empty?", description: "returns true because nothing has no contents.", examples: %w[nothing.empty? Nothing.new.empty? Nothing.new(1).empty?] }, "to_string" => { name: "to_string", description: "returns an empty string for nothing.", examples: %w[ nothing.to_string Nothing.new.to_string Nothing.new(1).to_string ] }, "inspect" => { name: "inspect", description: "returns the source string for nothing.", examples: %w[ nothing.inspect Nothing.new.inspect Nothing.new(1).inspect ] } }.freeze
Constants inherited from Code::Object
CLASS_FUNCTIONS, NUMBER_CLASSES
Constants included from Concerns::Shared
Concerns::Shared::COMPOUND_ASSIGNMENT_OPERATORS, Concerns::Shared::OPERATOR_METHOD_ALIASES, Concerns::Shared::SHARED_OPERATORS
Instance Attribute Summary
Attributes included from Concerns::Shared
Class Method Summary collapse
Instance Method Summary collapse
- #call(**args) ⇒ Object
- #code_empty? ⇒ Boolean
- #code_inspect ⇒ Object
- #code_to_string ⇒ Object
-
#initialize(*_args, **_kargs, &_block) ⇒ Nothing
constructor
A new instance of Nothing.
- #nothing? ⇒ Boolean
- #present? ⇒ Boolean
- #truthy? ⇒ Boolean
Methods inherited from Code::Object
class_documentation, class_functions, code_new, #code_new, documentation, documentation_for, documented_functions_for, function_documentation_for, function_documentation_registry_for, functions, inherited_function_documentation_for, instance_functions, maybe, #name, repeat, sorted_dictionary, |
Methods included from Concerns::Shared
#<=>, #==, #as_json, #blank?, #code_and, #code_as_json, #code_blank?, #code_class_functions, #code_compare, #code_deep_duplicate, #code_different, #code_documentable_functions, #code_documentation, #code_duplicate, #code_dynamic_call, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_false?, #code_falsy?, code_fetch, #code_fetch, #code_functions, code_get, #code_get, #code_greater, #code_greater_or_equal, #code_has_key?, #code_inclusive_range, #code_instance_functions, #code_instance_of?, #code_is_a?, #code_itself, #code_less, #code_less_or_equal, #code_name, #code_nothing?, #code_or, #code_presence, #code_presence_in, #code_present?, #code_respond_to?, #code_same_object?, #code_self, #code_send, code_set, #code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_tap, #code_then, #code_to_boolean, #code_to_class, #code_to_date, #code_to_decimal, #code_to_dictionary, #code_to_duration, #code_to_integer, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_time, #code_true?, #code_truthy?, #eql?, #falsy?, #hash, #inspect, #multi_fetch, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s
Constructor Details
#initialize(*_args, **_kargs, &_block) ⇒ Nothing
Returns a new instance of Nothing.
43 44 45 |
# File 'lib/code/object/nothing.rb', line 43 def initialize(*_args, **_kargs, &_block) self.raw = nil end |
Class Method Details
.function_documentation(scope) ⇒ Object
37 38 39 40 41 |
# File 'lib/code/object/nothing.rb', line 37 def self.function_documentation(scope) return INSTANCE_FUNCTIONS if scope == :instance {} end |
Instance Method Details
#call(**args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/code/object/nothing.rb', line 47 def call(**args) code_operator = args.fetch(:operator, nil).to_code case code_operator.to_s when "empty?" sig(args) code_empty? else super end end |
#code_empty? ⇒ Boolean
71 72 73 |
# File 'lib/code/object/nothing.rb', line 71 def code_empty? Boolean.new(true) end |
#code_inspect ⇒ Object
79 80 81 |
# File 'lib/code/object/nothing.rb', line 79 def code_inspect String.new("nothing") end |