Class: Village
- Inherits:
-
Object
- Object
- Village
- Defined in:
- lib/rwanda/village.rb
Instance Attribute Summary collapse
-
#cell ⇒ Object
Returns the value of attribute cell.
-
#district ⇒ Object
Returns the value of attribute district.
-
#province ⇒ Object
Returns the value of attribute province.
-
#sector ⇒ Object
Returns the value of attribute sector.
-
#village ⇒ Object
Returns the value of attribute village.
Instance Method Summary collapse
- #[](n) ⇒ Object
-
#initialize(row) ⇒ Village
constructor
A new instance of Village.
- #match(str) ⇒ Object
- #to_s ⇒ Object
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
#cell ⇒ Object
Returns the value of attribute cell.
2 3 4 |
# File 'lib/rwanda/village.rb', line 2 def cell @cell end |
#district ⇒ Object
Returns the value of attribute district.
2 3 4 |
# File 'lib/rwanda/village.rb', line 2 def district @district end |
#province ⇒ Object
Returns the value of attribute province.
2 3 4 |
# File 'lib/rwanda/village.rb', line 2 def province @province end |
#sector ⇒ Object
Returns the value of attribute sector.
2 3 4 |
# File 'lib/rwanda/village.rb', line 2 def sector @sector end |
#village ⇒ Object
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_s ⇒ Object
7 8 9 |
# File 'lib/rwanda/village.rb', line 7 def to_s "#{@province}/#{@district}/#{@sector}/#{@cell}/#{@village}" end |