Class: Toolx::Core::Concerns::Inquirer::SymbolInquiry

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/toolx/core/concerns/inquirer.rb

Instance Method Summary collapse

Constructor Details

#initialize(sym) ⇒ SymbolInquiry

Returns a new instance of SymbolInquiry.

Raises:

  • (ArgumentError)


10
11
12
13
# File 'lib/toolx/core/concerns/inquirer.rb', line 10

def initialize(sym)
  raise ArgumentError, 'Must be a Symbol' unless sym.is_a?(Symbol)
  sym.is_a?(::Toolx::Core::Concerns::Inquirer::SymbolInquiry) ? super(sym.__getobj__) : super(sym)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/toolx/core/concerns/inquirer.rb', line 15

def method_missing(method_name, *args, &block)
  if method_name.to_s.end_with?('?')
    __getobj__.to_s == method_name.to_s.delete_suffix('?')
  else
    super
  end
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
# File 'lib/toolx/core/concerns/inquirer.rb', line 32

def ==(other)
  __getobj__ == other.to_sym
end

#inspectObject



27
# File 'lib/toolx/core/concerns/inquirer.rb', line 27

def inspect = __getobj__.inspect

#is_a?(klass) ⇒ Boolean

Returns:

  • (Boolean)


30
# File 'lib/toolx/core/concerns/inquirer.rb', line 30

def is_a?(klass) = klass == Symbol || super

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/toolx/core/concerns/inquirer.rb', line 23

def respond_to_missing?(method_name, include_private = false)
  method_name.to_s.end_with?('?') || super
end

#to_sObject



28
# File 'lib/toolx/core/concerns/inquirer.rb', line 28

def to_s = __getobj__.to_s

#to_symObject



29
# File 'lib/toolx/core/concerns/inquirer.rb', line 29

def to_sym = __getobj__