Sha256: e9a4a4cc4fc34c9931b41cba9cfa9b59cb4f811a01f0330630224d4f02f5ba9b
Contents?: true
Size: 894 Bytes
Versions: 26
Compression:
Stored size: 894 Bytes
Contents
#!/usr/bin/env ruby class Attribute attr_accessor :name attr_accessor :space def initialize(name, space) @name = name @space = space end def to_s raise 'child must implement' end end class AttributeSetter < Attribute def to_s "\n#{space}def #{name}=(#{name})\n#{space} @#{name} = #{name}\n#{space}end" end end class AttributeGetter < Attribute def to_s "\n#{space}def #{name}\n#{space} @#{name}\n#{space}end" end end names = [] objects = [] STDIN.each_line do |line| name = line.chomp space = name.scan(/^\s+/)[0].to_s name = name.gsub(/^\s+/, '') name = name.gsub(/\W+/, '_') name = name.downcase names.push(name) objects.push(AttributeGetter.new(name, space)) objects.push(AttributeSetter.new(name, space)) end names.sort.each do |name| objects.each do |object| if object.name == name puts object end end end
Version data entries
26 entries across 26 versions & 1 rubygems