Class: Helium::Console::Registry::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/helium/console/registry.rb

Defined Under Namespace

Classes: LazyStringEvaluator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, **options) ⇒ Element

Returns a new instance of Element.



21
22
23
24
# File 'lib/helium/console/registry.rb', line 21

def initialize(object, **options)
  @object = object
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



47
48
49
50
51
52
# File 'lib/helium/console/registry.rb', line 47

def method_missing(name, *args)
  return @options[name] if @options.key?(name)
  return ColorizedString.new(*args).colorize(name) if ColorizedString.colors.include?(name)

  super
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



29
30
31
# File 'lib/helium/console/registry.rb', line 29

def object
  @object
end

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/helium/console/registry.rb', line 29

def options
  @options
end

Instance Method Details

#callObject



26
27
# File 'lib/helium/console/registry.rb', line 26

def call
end

#format(other_object, **options) ⇒ Object



35
36
37
# File 'lib/helium/console/registry.rb', line 35

def format(other_object, **options)
  Helium::Console.format(other_object, **nested_opts(options, increase_level: false))
end

#format_nested(other_object, **options) ⇒ Object



31
32
33
# File 'lib/helium/console/registry.rb', line 31

def format_nested(other_object, **options)
  Helium::Console.format(other_object, **nested_opts(options))
end

#format_string(string, **options) ⇒ Object



39
40
41
# File 'lib/helium/console/registry.rb', line 39

def format_string(string, **options)
  Helium::Console.format_string(string, **options)
end

#respond_to_missing?(name, private = false) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/helium/console/registry.rb', line 54

def respond_to_missing?(name, private = false)
  @options.key?(name) || ColorizedString.colors.include?(name) || super
end

#simple?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/helium/console/registry.rb', line 43

def simple?
  false
end