1
0
Fork 0
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:
Zach Gollwitzer 2024-08-22 14:54:14 -04:00
parent 4433488562
commit 5ea2fd5a23
17 changed files with 258 additions and 2 deletions

20
app/models/measurement.rb Normal file
View 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