Class: Ecoportal::API::V1::SchemaField
- Inherits:
-
Common::BaseModel
- Object
- Common::BaseModel
- Ecoportal::API::V1::SchemaField
- Defined in:
- lib/ecoportal/api/v1/schema_field.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Common::BaseModel
Instance Method Summary collapse
Methods inherited from Common::BaseModel
#as_json, #as_update, #consolidate!, #dirty?, #doc, embeds_one, #initial_doc, #initialize, #original_doc, passthrough, #print_pretty, #replace_doc!, #replace_original_doc!, #reset!, #to_json
Methods included from Common::BaseClass
#class_resolver, #redef_without_warning, #resolve_class
Constructor Details
This class inherits a constructor from Ecoportal::API::Common::BaseModel
Instance Method Details
#parse_text(value) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ecoportal/api/v1/schema_field.rb', line 7 def parse_text(value) values = [*value.to_s.lines].map do |line| line = line.chomp next if line == "" case type when "text", "phone_number" line when "number" Float(line) rescue return nil, false when "boolean" %w[true TRUE True Y y YES X x].include?(line) when "select" return nil, false unless .include?(line) line when "date" Date.parse(line) rescue return nil, false end end.compact out = values out = values.first unless multiple [out, true] end |