I have data inside of a ruby class method that i want to filter. The class method Clothes.data contains the following array
Clothes.data class method
[
{
"Type"=>"Sweater",
"Size"=>"Large",
"Material"=>"Wool"
},
{
"Type"=>"Hoodie",
"Size"=>"Medium",
"Material"=>"Cotton"
},
{
"Type"=>"Jeans",
"Size"=>"Small",
"Material"=>"Denim"
}
]
I want to filter the string "Wool" from the class method Clothes.data . And then return the string reversed. Here's what I have tried.
def nice_material
Clothes.data.map @Material.reverse
end
This currently returns the array => ["Wool", "Wool", "Wool"] . The instance method @Material represents the first Material.
Aucun commentaire:
Enregistrer un commentaire