Module: AccessibleIndex

Included in:
RedShift::Component::PhaseItem, RedShift::Transition, TestArray
Defined in:
lib/redshift/util/accessible-index.rb

Instance Method Summary collapse

Instance Method Details

#index_accessor(h) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/redshift/util/accessible-index.rb', line 2

def index_accessor(h)
  h.each do |sym, idx|
    define_method sym do
      self[idx]
    end
    define_method "#{sym}=" do |val|
      self[idx] = val
    end
  end
end

#index_reader(h) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/redshift/util/accessible-index.rb', line 13

def index_reader(h)
  h.each do |sym, idx|
    define_method sym do
      self[idx]
    end
  end
end

#index_writer(h) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/redshift/util/accessible-index.rb', line 21

def index_writer(h)
  h.each do |sym, idx|
    define_method "#{sym}=" do |val|
      self[idx] = val
    end
  end
end