Module: Ncase

Defined in:
lib/ncase.rb,
lib/ncase/words.rb,
lib/ncase/version.rb

Overview

Contains convenience methods for one-off use.

Defined Under Namespace

Classes: Words

Constant Summary collapse

VERSION =
"0.2.1"

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)

Delegate <name> to Words#<name>_case if it’s defined.



11
12
13
14
15
16
17
# File 'lib/ncase.rb', line 11

def method_missing(name, *args)
  if (method = Words.public_instance_method("#{name}_case"))
    method.bind(Words.new(*args)).call
  else
    super
  end
end

Class Method Details

.method_missing(name, *args) ⇒ Object

Delegate <name> to Words#<name>_case if it’s defined.



11
12
13
14
15
16
17
# File 'lib/ncase.rb', line 11

def method_missing(name, *args)
  if (method = Words.public_instance_method("#{name}_case"))
    method.bind(Words.new(*args)).call
  else
    super
  end
end

.respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ncase.rb', line 19

def respond_to_missing?(name, *)
  Words.public_instance_method("#{name}_case") || super
end