Class: Code::Object::Nothing
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
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
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 |