Class: Rh::Method
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#raw_name ⇒ Object
readonly
Returns the value of attribute raw_name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #escaped_name ⇒ Object
-
#initialize(options = {}) ⇒ Method
constructor
A new instance of Method.
- #url ⇒ Object
Methods included from HasUrl
Constructor Details
#initialize(options = {}) ⇒ Method
Returns a new instance of Method.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rh/method.rb', line 10 def initialize(={}) @klass = ['klass'] @source = ['source'] @package = ['package'] @version = ['version'] @name = ['name'] match = name.match(/(#|::)(.+)/) raise "Invalid method name: #{name} in #{klass.name}" unless match @type = match[1] == '#' ? :instance : :class @raw_name = match[2] end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def name @name end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def package @package end |
#raw_name ⇒ Object (readonly)
Returns the value of attribute raw_name.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def raw_name @raw_name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def source @source end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/rh/method.rb', line 8 def version @version end |
Instance Method Details
#escaped_name ⇒ Object
22 23 24 |
# File 'lib/rh/method.rb', line 22 def escaped_name CGI.escape(raw_name).gsub('%', '-') end |
#url ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rh/method.rb', line 26 def url type_string = type == :class ? 'c' : 'i' case source when 'core' "#{core_url}/#{klass.escaped_name}.html#method-#{type_string}-#{escaped_name}" when 'stdlib' "#{stdlib_url}/#{package}/rdoc/#{klass.escaped_name}.html#method-#{type_string}-#{escaped_name}" else raise 'Unable to generate URL' end end |