Class: Ronin::Model::Types::Description

Inherits:
DataMapper::Property::Text
  • Object
show all
Defined in:
lib/ronin/model/types/description.rb

Overview

The Description property type is similar to the Text type, but automatically strips all leading and tailing white-space from every line.

Instance Method Summary collapse

Instance Method Details

#typecast(value) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Type-casts the description.

Parameters:

  • value (Object)

    The text of the description.

  • property (DataMapper::Property)

    The description property.

Returns:

  • (String, nil)

    The type-casted description.

Since:

  • 1.0.0



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ronin/model/types/description.rb', line 48

def typecast(value)
  case value
  when nil
    nil
  else
    sanitized_lines = []

    value.to_s.each_line do |line|
      sanitized_lines << line.strip
    end

    return sanitized_lines.join("\n").strip
  end
end