Is there a better way to get the public “properties” of a Ruby object?
def props self.public_methods.grep(/.=$/) - ["==","==="] end
Your regular expression is incomplete: it matches methods starting with any character, not just word characters. The best way to get all the "writers" is
methods.grep /^\w+=$/
And regex can be shortened to
methods.grep /\w=$/
but less clear.
, , , - , . , .
, , height_feet= height_meters= , , , @height_feet @height_meters @height_cubits.
height_feet=
height_meters=
@height_feet
@height_meters
@height_cubits
, , , .
, Ruby , "" . , (, , , Ruby), , , , .
, "" ", , ", , . (: "" , <=, >= !=, , .)
<=
>=
!=
Source: https://habr.com/ru/post/1780791/More articles:Compare each element in the array with each other - arraysNH QueryOver FetchMany Exception - vb.netPerformance profiler: how to use unsigned long to measure time in microseconds? - c ++Измените плагин jquery от подсчета слов к плагину символов? - jqueryQuestion with Scrapy Newbie - can't work with tutorial file - pythonUsing identifier in databases - databaseHeroku на Windows дает ошибку: Содержание Недействительный открытый ключ - windowsАвтоматически останавливать пакетные сборки командной строки Visual С++ 2008 при первой ошибке компиляции с использованием devenv.exe? - msbuildpython unix service library - pythonHow to combine PNGS with alpha channels into one enlarged image? - phpAll Articles