Class: Axel::Inspector

Inherits:
Object
  • Object
show all
Defined in:
lib/axel/inspector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, parens_params = [], attributes = []) ⇒ Inspector

Returns a new instance of Inspector.



13
14
15
16
17
# File 'lib/axel/inspector.rb', line 13

def initialize(object, parens_params = [], attributes = [])
  self.object = object
  self.parens_params = hasherize parens_params
  self.attributes = hasherize attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



11
12
13
# File 'lib/axel/inspector.rb', line 11

def attributes
  @attributes
end

#objectObject

Returns the value of attribute object.



9
10
11
# File 'lib/axel/inspector.rb', line 9

def object
  @object
end

#parens_paramsObject

Returns the value of attribute parens_params.



10
11
12
# File 'lib/axel/inspector.rb', line 10

def parens_params
  @parens_params
end

Instance Method Details

#class?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/axel/inspector.rb', line 35

def class?
  object.is_a?(Class)
end

#inspectObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/axel/inspector.rb', line 19

def inspect
  class_name.tap do |string|
    string << "(#{display_parens})" unless parens_params.empty?
    string << " #{display_attributes}" unless attributes.empty?
    unless class?
      string.prepend "#<"
      string << ">"
    end
  end
end