What module do the class `Hash`, `Array`, `File` belong to? [closed] - ruby

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Simple question:
What module do the class Hash, Array, File belong to ?
Would you just say that they are part of the ruby core?

They are instances of the Class module (class).

Classes don't "belong to modules". They are just objects like any other object. If you are asking about the constants Hash, Array, File, etc., those belong to the Object class. All constants that are not explicitly defined in some specific module belong to Object.

The simple answer to the simple question is Yes they are part of Ruby Core

Yes. Hash, Array, File they all belongs to core.

Related

What is this specific method called? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I'm curios as to what this specific method is called:
public Word(String word) {
this._word = word;
}
Thanks in advance!
This is called a constructor. In this case, it would be for a Word object. It takes parameters to assign values to instance variables (in this case, the String word.)
Here is a link to the Oracle documentation on providing constructors in Java for further reference.

Ruby objects without 'to_s' [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Are there any objects in ruby that don't respond to to_s?
The question isn't meant to ask whether it is possible to create one, which I know can be done by undef_method. Feel free to explain details, including caveats of undefining.
The BasicObject class does not define a to_s method, so any instance of that class would not have a to_s method.
We should never specialize a subclass, since the subclass would not attend to the parent expectation anymore, have a look in the Liskov Substitution Principle.

String replace to method [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I need to replace a localized string to localized method.
From:
"social_1.localized()"
To:
"social_1".localized()
What is the best way to do?
May be this:
"social_1.localized()".gsub(".localized()","").localized()
or
my_string, my_method = "social_1.localized()".split('.')
my_method = my_method.gsub!("()",'').to_sym
my_string.send(my_method)
#uri-agassi (see comment) is right. using send this way may be a security risk. especially if it comes from user input (i.e. from the params object). you could think about to whitelist callable methods:
if [:upcase, :downcase, :capitalize].include?(my_method)
my_string.send(my_method)
end
Or at least ask the object, that it knowns the method to call:
my_string.send(my_method) if my_string.respond_to?(my_method)

When creating a DSL in Ruby, is it possible to create an alternate version of `def`? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
It is possible to call define_method directly or from within a method call that accepts a block. But is it possible to create a new method or keyword that performs manipulation on code and then declares it into a method, but has the same syntax as the built-in def?
No. You can define a method, but you cannot define a keyword. Whatever method you define on the Module class, you cannot pass a method body to it without the do keyword, unlike with def.

sub-subclass concept in OWL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am posting this on stackoverflow since I am quite confused with OWL right now.
So in OWL file, can I represent a sub-subclass concept?
For example, entities belong to a class called Wine and it inside this class, we have a sub-class called WineType and then Within the WineType, we have sub-subclass called enzyme_avability. Would this be possible in OWL as a nested class concept? (e.g. )
Please help me with this
Yes it is possible. I think what you are looking for is here
http://www.w3.org/TR/owl2-syntax/#Object_Property_Restrictions
So in sort you are representing a hierarchy structure which is completely supported by OWL.
You can write axioms like:
A subClassOf B
B subClassOf C
and so on, without limits on the number of levels you want to define. A reasoner will be able to answer queries like: is A subclass of C? by following the hierarchy.
Of course, more complex ways to arrange the hierarchy exist, e.g., the object property restrictions mentioned by Jinal.

Resources