Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/method_analyzer.rb

Instance Method Summary collapse

Instance Method Details

#attr(name, writer = false) ⇒ Object



20
21
22
23
# File 'lib/method_analyzer.rb', line 20

def attr(name, writer=false)
  attr_reader name
  attr_writer name if writer
end

#attr_accessor(*names) ⇒ Object



15
16
17
18
# File 'lib/method_analyzer.rb', line 15

def attr_accessor(*names)
  attr_reader(*names)
  attr_writer(*names)
end

#attr_reader(*names) ⇒ Object



3
4
5
6
7
# File 'lib/method_analyzer.rb', line 3

def attr_reader(*names)
  names.each do |name|
    module_eval "def #{name}() @#{name} end"
  end
end

#attr_writer(*names) ⇒ Object



9
10
11
12
13
# File 'lib/method_analyzer.rb', line 9

def attr_writer(*names)
  names.each do |name|
    module_eval "def #{name}=(x) @#{name}=x end"
  end
end