I have an array of strings that are supposed to be used as constraints when creating a new class.
They look like this:
constraint :name, 'name.size > 0'
constraint :name, 'name =~ /^[A-Z]/'
And are, as you can see, made up of ‘name’ which is going to be an attribute (and will have methods for get/set the values it holds)
the constraint itself are valid ruby booleans.
What is the best way to get the info needed from these strings, and to implement them in the methods?
As of now i’m trying to chop up the string, something like this:
y = String.index("'")
x = String.length
newstr = String[x,y]
and so on, but this really feels like i’m making it harder than it is..
Try the Split method. If you want only the information after the ‘ use it like this: