module MITS::V4_1::Mapper::UnitsMapper

Public Instance Methods

units(tags) click to toggle source
# File lib/mits/v4.1/mapper/units_mapper.rb, line 5
def units(tags)
  tags = [tags] unless tags.is_a? Array
  tags.map do |tag|
    Unit.new(bathrooms: try(tag[:UnitBathrooms], :to_f),
             bedrooms:  try(tag[:UnitBedrooms], :to_f),
             name:      tag[:MarketingName],
             rent:      try(tag[:UnitRent], :to_f),
             sqft:      unit_sqft(tag))
  end
end

Private Instance Methods

unit_sqft(tag) click to toggle source
# File lib/mits/v4.1/mapper/units_mapper.rb, line 18
def unit_sqft(tag)
  min = tag[:MinSquareFeet]
  max = tag[:MaxSquareFeet]
  Range.new(min.to_i, max.to_i)
end