Class: Village

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ Village

Returns a new instance of Village.



4
5
6
# File 'lib/rwanda/village.rb', line 4

def initialize(row)
  @province,@district,@sector,@cell,@village=row['province'],row['district'],row['sector'],row['cell'],row['village']
end

Instance Attribute Details

#cellObject

Returns the value of attribute cell.



2
3
4
# File 'lib/rwanda/village.rb', line 2

def cell
  @cell
end

#districtObject

Returns the value of attribute district.



2
3
4
# File 'lib/rwanda/village.rb', line 2

def district
  @district
end

#provinceObject

Returns the value of attribute province.



2
3
4
# File 'lib/rwanda/village.rb', line 2

def province
  @province
end

#sectorObject

Returns the value of attribute sector.



2
3
4
# File 'lib/rwanda/village.rb', line 2

def sector
  @sector
end

#villageObject

Returns the value of attribute village.



2
3
4
# File 'lib/rwanda/village.rb', line 2

def village
  @village
end

Instance Method Details

#[](n) ⇒ Object



19
20
21
22
# File 'lib/rwanda/village.rb', line 19

def [](n)
  raise "Division index #{n} out of range!  Permitted indices 0 (province) to 4 (village)" unless (0..4).include? n
  self.send(Rwanda::DIVISIONS[n])
end

#match(str) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/rwanda/village.rb', line 10

def match(str)
  matches = []
  Rwanda::DIVISIONS.each do |div|
    if str.downcase == self.send(div).downcase
      matches.push div
    end
  end
  matches
end

#to_sObject



7
8
9
# File 'lib/rwanda/village.rb', line 7

def to_s
  "#{@province}/#{@district}/#{@sector}/#{@cell}/#{@village}"
end