Skip to content

Cannot create Unit object with hash #138

@Nowaker

Description

@Nowaker
    # Create a new Unit object.  Can be initialized using a String, a Hash, an Array, Time, DateTime
    #
    # @example Valid options include:
    # ...
    #  [1, 'kg']
    #  {:scalar => 1, :numerator=>'kg'}
    def initialize(*options)

The latter doesn't work as promised:

2.2.2 :012 > Unit.new({:scalar => 1, :numerator=>'kg'})
TypeError: no implicit conversion of Array into String
        from /home/nowaker/.rvm/gems/ruby-2.2.2/gems/ruby-units-2.0.0/lib/ruby_units/unit.rb:410:in `+'
        from /home/nowaker/.rvm/gems/ruby-2.2.2/gems/ruby-units-2.0.0/lib/ruby_units/unit.rb:410:in `is_base?'
        from /home/nowaker/.rvm/gems/ruby-2.2.2/gems/ruby-units-2.0.0/lib/ruby_units/unit.rb:1246:in `update_base_scalar'
        from /home/nowaker/.rvm/gems/ruby-2.2.2/gems/ruby-units-2.0.0/lib/ruby_units/unit.rb:344:in `initialize'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions