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.
9 10 11 12 13 14 15 |
# File 'lib/rh/klass.rb', line 9 def initialize(={}) @name = ['name'] @source = ['source'] @version = ['version'] @packages = ['packages'] @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/rh/klass.rb', line 7 def name @name end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
7 8 9 |
# File 'lib/rh/klass.rb', line 7 def packages @packages end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/rh/klass.rb', line 7 def source @source end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/rh/klass.rb', line 7 def version @version end |
Instance Method Details
#escaped_name ⇒ Object
17 18 19 |
# File 'lib/rh/klass.rb', line 17 def escaped_name name.gsub('::', '/') end |
#find_method_by_name(method_name) ⇒ Object
32 33 34 |
# File 'lib/rh/klass.rb', line 32 def find_method_by_name(method_name) methods.find { |method| method.name == method_name } end |
#find_methods_by_ambiguous_name(ambiguous_method_name) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/rh/klass.rb', line 36 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
44 45 46 47 48 49 50 |
# File 'lib/rh/klass.rb', line 44 def methods @methods ||= begin @options['methods'].map do |method| Rh::Method.new(method.merge('klass' => self, 'version' => version)) end end end |
#url ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rh/klass.rb', line 21 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 |