Class: Measurb::DimensionBuilder::ValueProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/measurb/dimension_builder.rb

Overview

Placeholder class in definition blocks for writing straightforward conversion syntax. Currently only supports multiplication and division.

Examples

Measurb.define :inches do
  feet value / 12.0
end

Measurb.define :feet do
  inches value * 12.0
end

Instance Method Summary collapse

Instance Method Details

#*(convert_value) ⇒ Proc

Handle a conversion by multiplication

Parameters:

  • convert_value (Float)

Returns:

  • (Proc)

    Proc to be used as the body for the conversion method on the dimension class



95
96
97
# File 'lib/measurb/dimension_builder.rb', line 95

def *(convert_value)
  proc { value * convert_value }
end

#/(convert_value) ⇒ Proc

Handle a conversion by division

Parameters:

  • convert_value (Float)

Returns:

  • (Proc)

    Proc to be used as the body for the conversion method on the dimension class



103
104
105
# File 'lib/measurb/dimension_builder.rb', line 103

def /(convert_value)
  proc { value / convert_value }
end