Class: Rh::Klass
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #escaped_name ⇒ Object
- #find_method_by_name(method_name) ⇒ Object
- #find_methods_by_ambiguous_name(ambiguous_method_name) ⇒ Object
-
#initialize(options = {}) ⇒ Klass
constructor
A new instance of Klass.
- #methods ⇒ Object
- #url ⇒ Object
Methods included from HasUrl
Constructor Details
#initialize(options = {}) ⇒ Klass
Returns a new instance of Klass.
7 8 9 10 11 12 13 |
# File 'lib/rh/klass.rb', line 7 def initialize(={}) @name = ['name'] @source = ['source'] @version = ['version'] @packages = ['packages'] = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rh/klass.rb', line 5 def name @name end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
5 6 7 |
# File 'lib/rh/klass.rb', line 5 def packages @packages end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/rh/klass.rb', line 5 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/rh/klass.rb', line 5 def version @version end |
Instance Method Details
#escaped_name ⇒ Object
15 16 17 |
# File 'lib/rh/klass.rb', line 15 def escaped_name name.gsub('::', '/') end |
#find_method_by_name(method_name) ⇒ Object
30 31 32 |
# File 'lib/rh/klass.rb', line 30 def find_method_by_name(method_name) methods.find { |method| method.name == method_name } end |
#find_methods_by_ambiguous_name(ambiguous_method_name) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/rh/klass.rb', line 34 def find_methods_by_ambiguous_name(ambiguous_method_name) if ambiguous_method_name.start_with?('#') || ambiguous_method_name.start_with?('::') methods.select { |method| method.name == ambiguous_method_name } else methods.select { |method| method.raw_name == ambiguous_method_name } end end |
#methods ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/rh/klass.rb', line 42 def methods @methods ||= begin ['methods'].map do |method| Rh::Method.new(method.merge('klass' => self, 'version' => version)) end end end |
#url ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rh/klass.rb', line 19 def url case source when 'stdlib' "#{stdlib_url}/#{packages.first}/rdoc/#{escaped_name}.html" when 'core' "#{core_url}/#{escaped_name}.html" else raise 'Unable to generate URL' end end |