Module: TrueUnits

Defined in:
lib/true_units.rb,
lib/true_units/version.rb,
lib/true_units/modules/true_units.rb

Constant Summary collapse

VERSION =
"0.0.1"
TRUE_UNITS_METHOD_NAME_PREFIX =
"tu_"
TRUE_UNITS_METHOD_NAME_PATTERN =
/^tu_[a-z]+$/

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



5
6
7
8
9
10
11
# File 'lib/true_units/modules/true_units.rb', line 5

def method_missing(name, *args, &block)
  if TRUE_UNITS_METHOD_NAME_PATTERN.match name
    true_units_string(name[TRUE_UNITS_METHOD_NAME_PREFIX.length..-1], self)
  else
    super.method_missing(name, *args, &block)
  end
end

Instance Method Details

#respond_to?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/true_units/modules/true_units.rb', line 13

def respond_to?(name, include_private = false)
  TRUE_UNITS_METHOD_NAME_PATTERN.match(name) || super
end