Class: UbigeoRails::Ubigeo
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- UbigeoRails::Ubigeo
- Defined in:
- app/models/ubigeo_rails/ubigeo.rb
Class Method Summary collapse
Instance Method Summary collapse
- #department_part ⇒ Object
- #district_part ⇒ Object
- #has_department? ⇒ Boolean
- #has_district? ⇒ Boolean
- #has_province? ⇒ Boolean
- #province_part ⇒ Object
Class Method Details
.children_of(*departments) ⇒ Object
49 50 51 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 49 def self.children_of(*departments) where(parent_id: departments) end |
.departments ⇒ Object
45 46 47 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 45 def self.departments with_parent nil end |
.with_parent(parent_id) ⇒ Object
41 42 43 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 41 def self.with_parent(parent_id) where parent_id: parent_id end |
Instance Method Details
#department_part ⇒ Object
29 30 31 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 29 def department_part id.to_s[0..1] end |
#district_part ⇒ Object
37 38 39 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 37 def district_part id.to_s[4..5] end |
#has_department? ⇒ Boolean
17 18 19 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 17 def has_department? digits >= 1 && digits <= 6 end |
#has_district? ⇒ Boolean
25 26 27 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 25 def has_district? digits >= 5 && digits <= 6 end |
#has_province? ⇒ Boolean
21 22 23 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 21 def has_province? digits >= 3 && digits <= 6 end |
#province_part ⇒ Object
33 34 35 |
# File 'app/models/ubigeo_rails/ubigeo.rb', line 33 def province_part id.to_s[2..3] end |