Project

Get_Set

0.0
No commit activity in last 3 years
No release in over 3 years
Creates instance method that can both get or set an instance variable. It's like squeezing :attr_writer into :attr_reader.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Get_Set

A Ruby gem that provides an alternative to :attr_accessor. The difference is the setters lack = sign.

Use It

Install:

gem install Get_Set

Use:

require "Get_Set"

class Uni_Bash

  include Get_Set::DSL

  attr_get_set :name, :age, :homes, :var_and_block, :vars_and_block
  
end

o = Uni_Bash.new

# --- Setters
o.name "Uncle Martin"     
o.age  190
o.homes "Mars", "California"
o.var_and_block(:a) { :b }
o.vars_and_block(:a, :b, :c) { :d }

# ---- Getters
o.name           # --> 'Uncle Martin
o.age            # --> 190
o.homes          # --> [ 'Mars', 'California' ]
o.var_and_block  # --> [ :a, Proc Instance ]
o.vars_and_block # --> [ [:a, :b, :c], Proc Instance ]</pre>