#!/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