ruby - Looping through nested modules -
I have created a module structure to capture the static data, something that I did not want to store in a database:
module Wixon module ketterz module Amazon module THREE_D_PRINTED_PRODUCTS REFERAL_FEE_PERCENTAGE = .12 MINIMUM_REFERAL_FEE = 0 NAME = 'end of 3D printed product' module AMAZON_DEVICE_ACCESSORIES REFERAL_FEE_PERCENTAGE = .25 MINIMUM_REFERAL_FEE = 0 NAME = 'Amazon Device Accessories End module of AMAZON_KINDLE REFERAL_FEE_PERCENTAGE = .15 MINIMUM_REFERAL_FEE = 0 NAME = 'Amazon Rugged 'end module AUTOMOTIVE_AND_POWERSPORTS REFERAL_FEE_PERCENTAGE = .12 MINIMUM_REFERAL_FEE = 1.00 NAME =' Amazon Kindle 'End End End
I am trying to select elements under the module. Is it possible to loop each module:
Wixon :: Katarias :: Amazon. Ish | Category | Print Category :: NAME}
I know that this code does not work like that.
I think that's possible what you are trying to do:
Vixen :: Cateories :: Amazon.constants.each do | Category | Print Vixen :: Cateories :: Amazon.const_get ("# {class} :: NAME") end
Comments
Post a Comment