How to set a hash member to a class so Rubymine can offer autocompletion from that class?

I'm a beginner in Ruby and Rubymine so sorry if this is an obvious question.

I'm creating a hash and adding an object from a specific class to it. For example:

measures = Hash.new

measures["weight"] = Measurement.new

Understandably, since typing is not static the object type is not explicitly stated so I want to know if there's a way to tell Rubymine measures["weight"] is going to be an object of the Measurement class so it can suggest me the methods from that class in the autocompletion feature.

 

0
3 comments

Hello,

at the moment it's not supported so could you please add your vote to the corresponding feature request:
https://youtrack.jetbrains.com/issue/RUBY-28895

0

I am new to ruby and rubmine. I am trying to use ruby mine.

Why is my autocomplete not working for doB() ? Am i doing something wrong?or is it expected? My Insite

module Xyz;
    class A
     def doA()
     end
    end 
end 

module Xyz
  class B
    def doB()
    end
  end
end


module Xyz 

 class C
   define initialize(b)
     #injecting instance of Xyz::B into C
     @b = b
   end
   def doC()
     a = Xyz::A.new 
     a.doA()  #Autocompletes workshere
     b.doB()  #Doesnot autocomplete, so suggestions shown
   end
 end 
end
0

TerryRector3 do you manage to run this code successfully? In my case it failed. 

0

Please sign in to leave a comment.