halogenandtoast / alchemist

A scientific conversion library.
155 stars 28 forks source link

Cannot register measurement using Alchemist.register #35

Closed jph closed 10 years ago

jph commented 10 years ago

Tested with Ruby 2.0.0p451 and Ruby 2.1.1p76

Alchemist.reset! also does not work, although other class methods do (.setup, .measure).

irb(main):001:0> require 'alchemist'
=> true
irb(main):002:0> Alchemist.register
NoMethodError: undefined method `register' for Alchemist:Module
    from (irb):2
    from /home/jph/.rbenv/versions/2.0.0-p451/bin/irb:12:in `<main>'
irb(main):003:0> Alchemist.reset!
NoMethodError: undefined method `reset!' for Alchemist:Module
    from (irb):3
    from /home/jph/.rbenv/versions/2.0.0-p451/bin/irb:12:in `<main>'
halogenandtoast commented 10 years ago

@jph, both methods are not in the current release of alchemist, but will be in the next. If you pulled alchemist down from github and did the following it would work.

> $LOAD_PATH.unshift "./lib"
> require "alchemist"
=> true
> Alchemist.setup
=> [:absorbed_radiation_dose, :angles, :area, :capacitance, :distance, :dose_equivalent, :electric_charge, :electric_conductance, :electrical_impedance, :electromotive_force, :energy, :frequency, :force, :illuminance, :inductance, :information_storage, :luminous_flux, :luminous_intensity, :magnetic_flux, :magnetic_inductance, :mass, :power, :pressure, :radioactivity, :time, :volume, :density, :temperature]
> Alchemist.register(:time, [:atomus], (1/376r).minutes.to.seconds.value)
=> [:atomus]
> 1.atomus.to.minutes.value
=> 0.0026595744680851068
> Alchemist.reset!
=> nil
> 1.atomus.to.minutes.value
NoMethodError: undefined method `first' for false:FalseClass
> 1.second
=> #<Alchemist::Measurement:0x007f93b9f1ec40 @value=1.0, @unit_name=:second, @exponent=1.0>

I'm going to try and release a new version some time between this and next week.

halogenandtoast commented 10 years ago

FYI, reset! doesn't actually seem to be doing what I want it to.

jph commented 10 years ago

Thanks, I didn't think to check that. Will wait on the next release, cheers.