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

Version Path
ix-cli-0.0.27 bin/ix-ruby-setter-methods
ix-cli-0.0.26 bin/ix-ruby-setter-methods
ix-cli-0.0.25 bin/ix-ruby-setter-methods
ix-cli-0.0.24 bin/ix-ruby-setter-methods
ix-cli-0.0.23 bin/ix-ruby-setter-methods
ix-cli-0.0.22 bin/ix-ruby-setter-methods
ix-cli-0.0.21 bin/ix-ruby-setter-methods
ix-cli-0.0.20 bin/ix-ruby-setter-methods
ix-cli-0.0.19 bin/ix-ruby-setter-methods
ix-cli-0.0.18 bin/ix-ruby-setter-methods
ix-cli-0.0.17 bin/ix-ruby-setter-methods
ix-cli-0.0.16 bin/ix-ruby-setter-methods
ix-cli-0.0.15 bin/ix-ruby-setter-methods
ix-cli-0.0.14 bin/ix-ruby-setter-methods
ix-cli-0.0.13 bin/ix-ruby-setter-methods
ix-cli-0.0.12 bin/ix-ruby-setter-methods
ix-cli-0.0.11 bin/ix-ruby-setter-methods
ix-cli-0.0.10 bin/ix-ruby-setter-methods
ix-cli-0.0.9 bin/ix-ruby-setter-methods
ix-cli-0.0.7 bin/ix-ruby-setter-methods