module Eapi::Methods::Types

Public Class Methods

check_asking_type(method, obj) click to toggle source
# File lib/eapi/methods/types.rb, line 16
def self.check_asking_type(method, obj)
  type = Types.type_question_method method
  if type
    obj.is?(type)
  else
    nil
  end
end
to_type_sym(x) click to toggle source
# File lib/eapi/methods/types.rb, line 25
def self.to_type_sym(x)
  x.to_s.underscore.to_sym
end
type_question_method(method) click to toggle source
# File lib/eapi/methods/types.rb, line 4
def self.type_question_method(method)
  ms = method.to_s
  return false unless ms.end_with?('?')
  if ms.start_with?('is_a_')
    ms.sub('is_a_', '').sub('?', '')
  elsif ms.start_with?('is_an_')
    ms.sub('is_an_', '').sub('?', '')
  else
    nil
  end
end