Module: Qdocs::Helpers

Included in:
Const, Method
Defined in:
lib/qdocs.rb

Instance Method Summary collapse

Instance Method Details

#find_constant(const) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/qdocs.rb', line 34

def find_constant(const)
  case const
  when Symbol, String
    Object.const_get const
  else
    const
  end
rescue NameError
  raise UnknownClassError, "Unknown constant #{const}"
end

#own_methods(methods) ⇒ Object



22
23
24
# File 'lib/qdocs.rb', line 22

def own_methods(methods)
  methods - Object.methods
end

#params_to_hash(params) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/qdocs.rb', line 26

def params_to_hash(params)
  hsh = {}
  params.each_with_index do |prm, i|
    hsh[prm[1] || "unnamed_arg_#{i}"] = prm[0]
  end
  hsh
end

#source_location_to_str(source_location) ⇒ Object



16
17
18
19
20
# File 'lib/qdocs.rb', line 16

def source_location_to_str(source_location)
  if source_location && source_location.length == 2
    "#{source_location[0]}:#{source_location[1]}"
  end
end