Logan Capaldo wrote:
#constants is getting the constants directly. (What you want is the values of the constants.) AFAIK there is no built in way to do this. The code isn't terribly long though anyway is it?
class Module
def constant_values
constants.map { |constant| const_get(constant) }
end
end
ri says that Module#constants returns an array of constant names. For some reason this reminds me of this bit of _Alice Through the Looking Glass_, where Alice is talking to the Knight,
'The name of the song is called "Haddocks' Eyes".'
`Oh, that's the name of the song, is it?' Alice said, trying to feel interested.
`No, you don't understand,' the Knight said, looking a little vexed. `That's what the name is called. The name really is "The Aged Aged Man".'
`Then I ought to have said "That's what the song is called"?' Alice corrected herself.
`No, you oughtn't: that's quite another thing! The song is called "Ways and Means": but that's only what it's called, you know!'
`Well, what is the song, then?' said Alice, who was by this time completely bewildered.
`I was coming to that,' the Knight said. `The song really is "A-sitting On a Gate": and the tune's my own invention.'The name of the song is called "Haddocks' Eyes".'
`Oh, that's the name of the song, is it?' Alice said, trying to feel interested.
`No, you don't understand,' the Knight said, looking a little vexed. `That's what the name is called. The name really is "The Aged Aged Man".'
`Then I ought to have said "That's what the song is called"?' Alice corrected herself.
`No, you oughtn't: that's quite another thing! The song is called "Ways and Means": but that's only what it's called, you know!'
`Well, what is the song, then?' said Alice, who was by this time completely bewildered.
`I was coming to that,' the Knight said. `The song really is "A-sitting On a Gate": and the tune's my own invention.'