mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Add backend for property account details
This commit is contained in:
parent
4433488562
commit
5ea2fd5a23
17 changed files with 258 additions and 2 deletions
20
app/models/measurement.rb
Normal file
20
app/models/measurement.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class Measurement
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_reader :value, :unit
|
||||
|
||||
VALID_UNITS = %w[sqft sqm]
|
||||
|
||||
validates :unit, inclusion: { in: VALID_UNITS }
|
||||
validates :value, presence: true
|
||||
|
||||
def initialize(value, unit)
|
||||
@value = value.to_f
|
||||
@unit = unit.to_s.downcase.strip
|
||||
validate!
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{@value.to_i} #{@unit}"
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue