Module: KRPC::Doc::SuffixMethods

Included in:
Client, Gen::ClassBase, Services::ServiceBase
Defined in:
lib/krpc/doc.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

DOCSTRING_SUFFIX =
"_doc"
DOCSTRING_SUFFIX_REGEX =
/^(.+)(?:#{DOCSTRING_SUFFIX}(=)?)$/

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



169
170
171
172
173
174
175
176
177
# File 'lib/krpc/doc.rb', line 169

def method_missing(method, *args, &block)
  if DOCSTRING_SUFFIX_REGEX =~ method.to_s
    documented_method_name = $1 + $2.to_s
    if respond_to? documented_method_name.to_sym
      return puts Doc.docstring_for_method(self,documented_method_name)
    end
  end
  super
end

Class Method Details

.included(base) ⇒ Object



165
166
167
# File 'lib/krpc/doc.rb', line 165

def self.included(base)
  base.extend self, ClassMethods
end

Instance Method Details

#respond_to_missing?(method) ⇒ Boolean

Returns:



179
180
181
182
183
184
# File 'lib/krpc/doc.rb', line 179

def respond_to_missing?(method, *)
  if DOCSTRING_SUFFIX_REGEX =~ method.to_s
    return true if respond_to? ($1 + $2.to_s).to_sym
  end
  super
end