Class: SAU::Regions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regions) ⇒ Regions

Returns a new instance of Regions.



5
6
7
# File 'lib/sau/regions.rb', line 5

def initialize(regions)
  @regions = regions
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



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

def method_missing(meth, *args)
  super(meth, args) unless meth.to_s =~ /^get_by_(\w+)$/
  value, prop = args.first, $1
  @regions.find { |region| region.send(prop.to_sym) == value }
end

Instance Attribute Details

#regionsObject (readonly)

Returns the value of attribute regions.



3
4
5
# File 'lib/sau/regions.rb', line 3

def regions
  @regions
end