class RealPage::AttributeParser
Parse the string value from the XML response into the configured data type
Attributes
type[R]
value[R]
Public Class Methods
new(value:, type:)
click to toggle source
@param value [String] the response value from RealPage
@param type [Symbol] the attribute's configured data type
# File lib/real_page/attribute_parser.rb, line 14 def initialize(value:, type:) @value = value @type = type end
Public Instance Methods
parse()
click to toggle source
@return [Object] the parsed attribute value
# File lib/real_page/attribute_parser.rb, line 20 def parse return unless value case type when :boolean AttributeParser::Boolean.new(value).parse when :date AttributeParser::Date.new(value).parse when :date_time AttributeParser::DateTime.new(value).parse when :decimal AttributeParser::Decimal.new(value).parse when :integer AttributeParser::Integer.new(value).parse when :object AttributeParser::Object.new(value).parse when :string AttributeParser::String.new(value).parse else raise ArgumentError, "Invalid attribute type: #{type}" end end